So I am attempting to create a zone implementation where if the amount of units with a certain tag exceeds the number of units with another tag an objective will be captured standing in the zone will capture an objective.
However, the problem occurs when counting the units and what the most optimal way of doing it is which is what I hope you guys can help me with! (Also if you have a better way of implementing it then I am all ears).
So in my implementation, I have added a game object with a box collider which is set as a trigger
collider
my idea was that as soon as a unit enters or leaves the script will update the count of users with a certain tag.
Should the count of one tag type be greater than the other the victory/capture condition will begin.
This is an ok solution however it has a major problem. Should one of the NPC's inside of the box collider die the script will never detect it as the body has never left the box.
So how do i overcome this problem in a sensable way?