Example #1
0
 public void OnTriggerEnter2D(Collider2D collision)
 {
     if (collision.gameObject.GetComponent <Enemy>() != null)
     {
         touched = true;
     }
     else if (collision.gameObject.tag == "Bullet")
     {
         Debug.Log("Was hit");
         health -= 50f;
         StartCoroutine(ChangeColor());
         if (health <= 0)
         {
             destroyed = true;
             Destroy(GetComponent <Rigidbody2D>());
             Destroy(GetComponent <BoxCollider2D>());
             StartCoroutine(Remove());
             scor.Add();
         }
         Destroy(collision.gameObject);
     }
 }