I am making a tower defense game (2D) and I am working on making the towers shoot the enemies. I want my turrent to shoot every 1 second and hit the enemy the closest to the front. My solution to this problem is by using circle colliders to detect if an enemy is in firing range, but I can not figure out how to shoot the enemy in first. I am stuck on trying to figure out how to put the enemies that are in the turrents range/collider2d in a list/enumerator/array (Whichever one is appropriate for storing gameobjects and can change length).
I looked through the documents and I couldnt find any collider2D function that lists the gameobjects in its range, so i need an alternative way to do it.
↧