/// <summary>
 /// Deal damage if we collide with player
 /// </summary>
 /// <param name="other">The collision object we collided with</param>
 private void OnCollisionEnter(Collision other)
 {
     if (other.gameObject.tag == "Player")
     {
         CharacterRigidBodyController playerController = other.gameObject.GetComponent <CharacterRigidBodyController>();
         playerController.Damage(damage);
     }
 }
Beispiel #2
0
 /// <summary>
 /// Upon player collision, attempt to apply damage
 /// </summary>
 /// <param name="other">The collider that triggered this event</param>
 private void OnTriggerEnter(Collider other)
 {
     // Only try to apply damage if it is the player object
     if (other.tag == "Player")
     {
         // Get the player class and use the Damage public function to apply damage
         CharacterRigidBodyController player = other.gameObject.GetComponent <CharacterRigidBodyController>();
         player.Damage(damage);
     }
 }