Checking Enemies In An Area.

Okay, I have a bunch of different sections scattered around the map. In these sections only so many enemies can be in at one time. How could I check which enemies are in the section. This would later be used to spawn/upgrade enemies.


Assuming you can define an area as a circle/sphere, one easy way would be to use Physics.OverlapSphere(). Another way would be to setup a collider that encompassed the area and set it to a trigger. you could keep track of enemies with OnTriggerEnter() and OnTriggerExit(). Or you could define your areas using Rects, get a list of all enemies based on tag, and then test if their XZ position was within each of the Rects.