Iam still working on my GTA2-Remake and part of that project is to simulate pedestrians and traffic. For not having to simulate a ridiculous amount of AI_characters and AI_vehicles that populate the entire city I spawn the respective actors inside a volume around the player.
For keeping track on how many cars and pedestrians are within that volume I have them register into lists (currently Iam using arrays but I read that probably sets are more performance efficient?). That requires me to make my “player frustum volume” make a lot of “OnBeginOverlap” and “OnEndOverlap” events. Of course only the actors that are character or vehicle AI actors are being added to the lists (Iam currently sorting that out by checking the actor names) but naturally also all other actors that are present in the level will fire these events.
Then, for finding suitable spawning locations I have to do some more overlap checks. For instance: When a car is supposed to be spawned a collision box with the approximate size of the car is placed at the potential spawning location and an overlap check is done. Only if the space is free the car is actually spawned.
And then, of course, each car has to sense a bit its surroundings in order to not constantly crash into each other. Therefore each AI_vehicle has a box collision component attached in front of itself that makes it aware when it has to break.
Finally there will be more overlap checks: At traffic lights (for telling the car to stop in the correct place), for crosswalks (both pedestrians and vehicles have to know if to wait or not) and i suppose that some more might come in the further development.
As you can see my current approach relies on a quite impressive amount of overlap checks. At least for my impression but Iam quite new in this entire business^^
So my question is: Is the approach Iam following reasonable for creating the game logic that I want to have? Or are the many overlap checks eventually a bit too costly? Iam still in my planning phase and could still quite simply switch strategies.
Many thanks and best wishes,