Esempio n. 1
0
 public void OnCollisionEnter(Collision collision)
 {
     if (collision.gameObject.CompareTag("Player")) //check object colliding in tag player
     {
         moveScript.life--;
         Debug.Log("life: " + moveScript.life);
         GameObject explosionprefab = Instantiate(explosion, gameObject.transform.position, transform.rotation); // instantieate a particle system
         Destroy(explosionprefab, 3f);                                                                           //destroy particle
         Destroy(gameObject);
         moveScript.ActiveImmune();
         if (moveScript.life == 0)
         {
             Destroy(collision.gameObject);
         }
     }
 }