Im running into a bit of a problem when trying to destroy one enemy gameobject at a time on touch. Currently in the scene I have several enemy gameobjects moving up the screen. The player taps/touches them to destroy them, but instead of just destroying one enemy gameobject, all of the enemy objects on screen get destroyed all at once when the player touches one. I’ve done some searching but I haven’t come across anything that really helps. Does anybody have any advice?
Here’s the code:
var hit : RaycastHit2D = Physics2D.Raycast(Camera.main.ScreenToWorldPoint((Input.GetTouch(0).position)), Vector2.zero);
if(hit.collider.gameObject.tag == "Bunny")
{
Destroy(hit.collider.gameObject);
}