Most effecient way to simulate a lot of traffic?

I have a city game where traffic should be simulated so cars can give the illusion of the city being more alive.
Of course, since the city can get quite large, it would be a bad idea to have all traffic being simulated and on-screen at once. My idea was to have the traffic teleporting around on the server, and the client tweens the traffic that is close to your character so that distant traffic isnt being simulated.

My problem, however, is that I’m not sure how I should go about making traffic able to get to one place from another. Since the traffic has to interact with each other (brake to cars in front of it and such), it kind of complicates things further. I would use something like PathfindingService, but I’ve had bad experiences with it and trying to simulate many agents, like stuttering, lag, etc.

So instead, I would want to use something else that would be able to effeciently figure out how to get to one place to another using connecting roads and not hitting other cars.

If anybody has any ideas as to what I could use to achieve this effect, your reply would be much appreciated.

Waypoints at each lane of the road. Cars would make a path to their destination and make an order of waypoints to go too. A raycast could be sent out from the front of the car, and if it hits another car, it stops moving.

2 Likes