Beispiel #1
0
 void OnTriggerEnter(Collider other)
 {
     if (other.gameObject.GetComponent <RaceCollidable>() != null)
     {
         RaceCollidable collidable = other.gameObject.GetComponent <RaceCollidable>();
         collidable.applyAllEffects(this);
     }
 }
Beispiel #2
0
 void OnCollisionEnter(Collision other)
 {
     if (other.gameObject.GetComponent <RaceCollidable>() != null)
     {
         RaceCollidable collidable = other.gameObject.GetComponent <RaceCollidable>();
         collidable.applyAllEffects(this);
     }
     else if (other.relativeVelocity.magnitude > 3)
     {
         GameObject explosion = GameObject.Instantiate(collisionExplosion);
         explosion.transform.position = transform.position;
         explosion.transform.parent   = transform;               // setting the parent here instead of during instantiation to avoid any potential scaling issues
         explosion.transform.rotation = transform.rotation;
     }
 }