void OnTriggerEnter2D(Collider2D hitInfo) { EnemyMovement enemy = hitInfo.GetComponent <EnemyMovement>(); TableHP table = hitInfo.GetComponent <TableHP>(); if (enemy != null) { Debug.Log("Party Boi"); hp = hp - 1; if (hp == 0) { health = health - 1; } StartCoroutine(ExampleCoroutine()); } if (table != null) { Debug.Log("Table"); hp = hp - 1; if (hp == 0) { health = health - 1; } StartCoroutine(ExampleCoroutine()); } Moving1 spider = hitInfo.GetComponent <Moving1>(); if (spider != null) { Debug.Log("Pinata"); hp = hp - 1; if (hp == 0) { health = health - 1; } StartCoroutine(ExampleCoroutine()); } if (health <= 0) { Destroy(gameObject); SceneManager.LoadScene("GameOver"); } }
void OnTriggerEnter2D(Collider2D hitInfo) { EnemyMovement enemy = hitInfo.GetComponent <EnemyMovement>(); TableHP table = hitInfo.GetComponent <TableHP>(); if (enemy != null) { enemy.TakeDamage(damage); } if (table != null) { table.TakeDamage(damage); } Moving1 spider = hitInfo.GetComponent <Moving1>(); if (spider != null) { spider.TakeDamage(damage); } Destroy(gameObject); }