Quantcast
Channel: Questions in topic: "physics 2d"
Viewing all articles
Browse latest Browse all 132

How to detect what Gameobjects are in a Collider2D? (C#)

$
0
0
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.

Viewing all articles
Browse latest Browse all 132

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>