Exemplo n.º 1
0
 private void OnTriggerEnter2D(Collider2D collision)
 {
     if (collision.tag != "Player")
     {
         Health_Lv3 enemyHealth = collision.gameObject.GetComponent <Health_Lv3>();
         if (enemyHealth != null)
         {
             enemyHealth.TakeDamage(damage);
         }
         Destroy(gameObject);
         return;
     }
 }
Exemplo n.º 2
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.name == "Walls")
        {
            Flip();
        }

        if (collision.tag == "Player")
        {
            Health_Lv3 playerHealth = collision.gameObject.GetComponent <Health_Lv3>();
            if (playerHealth != null)
            {
                playerHealth.TakeDamage(damage);
                collision.GetComponent <Player_Lv3>().KnockBack(transform);
                collision.GetComponent <Rigidbody2D>().AddForce(Vector2.left);
            }
        }
    }