Example #1
0
    void OnTriggerExit2D(Collider2D col)
    {
        if (col == null)
        {
            return;
        }

        // If the player hits the trigger...
        if (col.gameObject.tag == "Player")
        {
            HeroHealth pc = col.gameObject.GetComponent <HeroHealth>();
            pc.Kill();
        }
        else
        {
            Destroy(col.gameObject);
        }
    }
Example #2
0
 void OnCollisionEnter2D(Collision2D col)
 {
     Debug.Log("collision enter");
     // If the player hits the trigger...
     if (col == null)
     {
         return;
     }
     if (col.gameObject.tag == "Player")
     {
         HeroHealth pc = col.gameObject.GetComponent <HeroHealth>();
         pc.Kill();
     }
     else
     {
         Destroy(col.gameObject);
     }
 }