Esempio n. 1
0
 // collision checks, which only matter for the balls fired at players marked "Harmful"
 void OnCollisionEnter(Collision col)
 {
     if (col.gameObject.tag == "Harmful")
     {
         // we have to first check the color of the ball, as if it matches the color of the player then it is destroyed with no consequence, otherwise it kills the player
         ColorScript colorComponent = col.gameObject.GetComponent <ColorScript>();
         if ((colorComponent && colorComponent.IsMyColor(Player1)))
         {
             col.gameObject.GetComponent <BallScript>().DestroyBall();
         }
         else if (!colorComponent || (colorComponent && !colorComponent.IsMyColor(Player1)))
         {
             Respawn();
         }
     }
 }