Updated November 2026. Written by the Algosyntax team.
Quick answer: a car that follows a spline takes an afternoon. Traffic that shares a city with the player takes months, because every car needs the same stack of systems:
- A lane graph: connected lanes with directions and speed limits, not just road meshes.
- Junction rules: connector lanes, conflict points, signals, stop and yield signs, roundabouts and merges.
- Driving behaviour: car-following, safe gaps and lane changes.
- Spawning and performance: cars appear and vanish around the player, and hundreds of them must stay cheap.
- Gridlock and multiplayer: rules that lock up, and traffic that is expensive to replicate.
Day one: a car on a spline
Every traffic system starts the same way. A Blueprint moves a car along a spline with Get Location at Distance Along Spline, adding a little distance each frame. It works, and in a screenshot it looks like traffic.
Then a second road meets the first. Two cars reach the crossing at once. The player parks in the lane. Each of those needs a new system, and the systems depend on each other.
1. A lane graph, junctions included
Road meshes are for drawing. Cars need lanes: a line in the direction of travel with a width, a speed limit and links to the lanes it continues into. A road with two lanes each way is four lanes. A junction is a set of short connector lanes, one for each allowed move from an inbound lane to an outbound lane.
For each junction you decide which lane may turn where, shape a curve for each connector, and find where connectors cross or merge. Those conflict points are what the road rules protect. Build the lanes from the same data as the road mesh, or every road edit means fixing lanes by hand.
2. Right of way
Each kind of junction needs its own rule:
- Signals: green, yellow and all-red phases. A car turning across oncoming traffic still waits for a gap on green.
- Stop signs: a full stop, then first come, first served.
- Yield signs and priority roads: the minor road waits for a gap in major traffic.
- Roundabouts: entering cars give way to the ring.
- Merges: the ramp waits for a gap and the mainline never stops.
Two details catch everyone. A car told to go must keep that permission until it is through, or it stops in the middle of the junction. And a car should only enter when its exit lane has room.
3. Car-following, gaps and lane changes
Without a car-following model, cars drive through each other or brake in jerky steps. A common choice from traffic research is the Intelligent Driver Model: accelerate towards a desired speed, keep a minimum gap plus a time gap to the car ahead, and brake smoothly. The thing ahead can also be a merging car or a stop line.
Lane changes need a big enough gap, a new follower that won’t have to brake hard, and a real gain in speed. Without that last check, cars weave back and forth.
4. Spawning and performance
You can’t keep a car on every street. Cars spawn in a ring around the player and are removed when they get too far away. Each spawn needs a spot away from other cars, with room to stop before the next line. Pool the actors, because spawning a new actor is one of the most expensive steps.
For hundreds of cars, keep the simulation as plain data and let the actors only show it. Step it at a fixed rate, so a slow frame doesn’t change how cars drive. Update distant cars that are off screen less often, and keep collision off for background cars. Then profile it.
5. Gridlock
Rules that are each correct can still lock up. Four cars reach a four-way stop at once. A queue backs into a junction. A roundabout fills. You need a fair tie-break such as arrival order, the exit-space check above, a timer that relaxes the rules for a car that has waited too long and, as a last resort, removing a car that is truly stuck.
6. Multiplayer
Replicating hundreds of moving cars costs bandwidth and server time. Many games treat ambient traffic as cosmetic instead: each machine runs its own, and players don’t see the same cars. That is fine for background traffic. If one car matters to gameplay, such as a mission target, replicate that car on its own.
Your options in Unreal Engine
| Option | Good for | Watch out for |
|---|---|---|
| Spline-following Blueprints | A few cars on fixed loops | No junctions or rules: every crossing is hand-made |
| Mass and ZoneGraph, as in City Sample | Very large numbers of cars and crowds | Built around the sample’s own data and tools; expect C++ and study time |
| Your own system on a lane graph | Traffic that is the core of your game | Months of work across every step above |
| A plugin | Background traffic on the roads it builds | You work within its rules and limits |
Epic’s City Sample shows the large-scale route. Its city data comes from Houdini, its traffic lanes are built as a ZoneGraph, and traffic and crowds run on Mass, Unreal’s data-oriented entity framework. It’s worth studying, but it isn’t a drop-in traffic system for another project.
Build it or use a plugin?
Build it if traffic is your gameplay: cars that react to the player, crashes that cause jams, or a traffic management game. You’ll want control over every rule.
If traffic is background, a plugin saves those months. Our Any City Generator builds the roads and the lane graph together from one layout, so the rules arrive with the city. Its traffic stops at signals, gives way at stop and yield signs and roundabouts, merges onto highways and changes lanes, with the Intelligent Driver Model for following. The limits are clear: traffic is local and not replicated, cars don’t react to collisions, there are no pedestrians, and routes are random. The documentation covers the details.
FAQ
Can traffic use the NavMesh?
Not well. The NavMesh tells an agent where it can move. It has no lanes, directions or right of way. Cars need a lane graph.
Should every traffic car be a Chaos physics vehicle?
Usually not. Physics cars cost more and are harder to steer exactly along a lane. Many games move background cars along their lanes directly and keep physics for the player.
How many traffic cars can Unreal handle?
It depends on your meshes, your update rate and your target hardware, so profile your own scene. For thousands of agents, look at Mass.
Related articles
- How to Make a GTA-Style Game in Unreal Engine: What a Small Team Can Actually Build
- Procedural Cities in Unreal Engine: PCG, City Sample, Houdini or a Plugin?
- Chaos Vehicles or Arcade Physics? Choosing Car Handling for Your Game
- How to Make a Racing Game in Unreal Engine: What You Actually Need
- How to profile performance in Unreal Engine