The cost of overlap-checks for simulation of pedestrians and vehicles

Hey everyone,

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,

You’ll need to use some kind of LOD and clustering system, where distant traffic ticks every nth frame (check your overlaps in tick, not using the events which would check more than the tick rate) or inherits info from its neighbour, ie. when the car ahead brakes, 3 cars behind it also brake rather than checking them individually.

Thanks for this reply!
The idea of inheriting brake-signals is interesting, I try to think of a good implementation.
You said, that CheckOverlap-Events can be fired in a higher frequency than the tick rate? I always thought, that they actually are better to use (performance wise) than the EventTick…?
So, what you mean is, that it would be more effective to have an overlap-check every nth tick than using the BeginOverlap-Events and so on?