Beispiel #1
0
 void OnCollisionEnter2D(Collision2D collision)
 {
     if (collision.gameObject.tag == "Player" && !collisionFlag)
     {
         //Physics2D.IgnoreCollision (collision.gameObject.GetComponent<Collider2D>(), GetComponent<Collider2D>());
         collisionFlag = true;
         POCC.GameManager manager = POCC.GameManager.getInstance();
         manager.decrementHealth();
     }
 }
Beispiel #2
0
 /**
  * This will trigger when Pep come within the range of the enemy,
  * it will decrement the health as it is a discrete value on Pep.
  * DOUBLE CHECK THAT COLLISION2D IS OK.
  *
  * Also should probably have some kind of invulnerability period.
  * And should make him bounce somewehere.
  */
 void OnTriggerEnter2D(Collider2D pep)
 {
     Debug.Log("Trigger hit");
     if (pep.gameObject.tag == "Player")
     {
         if (!collisionFlag)
         {
             collisionFlag = true;
             POCC.GameManager manager = POCC.GameManager.getInstance();
             FindObjectOfType <AudioManager>().Play("damage");
             manager.decrementHealth();
             StartCoroutine(Knockback(0.02f, 300, pep.gameObject.transform.position, pep));
         }
     }
 }