Hi,
I have the following code which works, but I was wondering how it could be modified to find the DamageReceiver script if it was on the parent of the object that the projectile hit.
e.g.
I shoot the spaceship - I can find the script
I shoot the shield - I cannot – but is there a way I could?
function OnCollisionEnter( collision : Collision )
{
// find out where and what we hit
var contact : ContactPoint = collision.contacts[0];
var rotation = Quaternion.FromToRotation( Vector3.up, contact.normal );
// visual effects
var instantiatedExplosion : GameObject = Instantiate(explosion, contact.point, transform.rotation);
// tell the other object that they have been hit and how badly
if (contact.otherCollider.GetComponent(DamageReceiver))
{
contact.otherCollider.GetComponent(DamageReceiver).attacked = true;