I am making a game which would require objects (or civilians specifically) which would need to be generated around player.
Currently, I am using a custom system where I am spawning them randomly around the player as he walks upto a certain number. The civilians (non-important ones) are destroyed once the distance between them and the player goes beyond a certain limit.
For that, I have every civilian object occasionally check the distance between itself and the player. The number of civilians is somewhere around 100-120. The issue is it can be something of a performance hog.
There is also an occasional problem where if I keep the “maximum distance” between player and civilian before it gets destroyed too large, I run into empty sections of the city.
What I want to ask is that is there a better dynamic object generation that can deal with both the above mentioned issues.