Exemplo n.º 1
0
 // Check if player was hit by a projectile
 void OnTriggerEnter2D(Collider2D collider)
 {
     // note: 13 is projectile layer
     if (collider.gameObject.layer == 13)
     {
         Missile missile = collider.GetComponent <Missile>();
         // Add knock back force to player
         if (missile.GetFacingRight())
         {
             m_Rigidbody2D.AddForce(new Vector2(400f, 100f));
             m_HealthScript.LoseHealth();
         }
         else
         {
             m_Rigidbody2D.AddForce(new Vector2(-400f, 100f));
             m_HealthScript.LoseHealth();
         }
     }
 }