Simulating Traffic

Unity Traffic Simulation

Unity Traffic Simulation is a tool for easily adding simple traffic to existing virtual environments. Its interface simplicity makes it convenient to use in classroom settings.

Microsimulation models often produce two types of output: animated displays and numerical results in text files. The way these outputs are used is important.

Traffic Lights

Once the waypoint routes are implemented into the scene it is possible to connect traffic lights to them. This is done by using the dedicated editor window for this purpose. This window draws handles in the scene view over the end of a route to connect or disconnect route traffic signal lights.

The AI Python script is connected to the SUMO engine by the python manager class. Then a loop is created to train the AI. The loop first takes screenshots from all the junction cameras in the scene. Then it sends these screenshots to the python script to process. After the processing is completed the python script sets the action for each junction in the scene. This action is the state number that the junction needs to change to.

Once this has been set the AI will be ready to take over the control of the junction. Then it will calculate the traffic density and flow for each junction. The information is then fed back to the python script to calculate rewards.

Waypoint Routes

The traffic system uses a system of waypoint routes to move vehicles along predefined paths. The route consists of an interconnected set of waypoints that are configured with the aid of a dedicated user interface.

The asset is designed to be used with NavMesh so it requires that your roads/terrain are baked and have a mesh collider attached. The lane objects must also be attached to the traffic lanes game object to facilitate routing.

There are some bugs that occur when using this tool that prevent the traffic system from functioning as intended. One of these problems is triggered by vehicles that reach the end of their starting waypoint route at the same time.

When this happens, the vehicles will crash into each other and fall over. To prevent this from occurring, a collision blocker is deployed in the area of the starting waypoint route to stop vehicles from entering it. This will prevent vehicles from being loaded to the road and causing a gridlock.


The Unity game engine can easily create 3D environments and provide vehicles that are able to move on the roads. It also provides a tool for modeling vehicles’ physical properties and providing a platform for experimentation. The model allows researchers to tune granular vehicle parameters such as downforce, adherence to speed limits and top speed in mph. It also collects vehicle trajectories and collision data.

It can be used to test neural networks by analyzing the performance of different vehicle parameters and settings. It can also help users develop a simulated environment and visualize the results of reinforcement learning.

The Simple Traffic System asset features an editor that enables the rapid creation of waypoint based routes that can be interconnected in a modular manner to animate road networks. Its AI traffic logic is highly optimized using the C# job system and burst compiler to reduce cpu usage. The assets also include a set of tools that automate route configuration tasks and simplify the process of configuring traffic signals.


Depending on the type of intersection, there are different rules that need to be followed. For instance, intersections with STOP traffic can have one or more lanes. Each lane can be configured to either allow or block all cars. It is also possible to configure the two traffic lights that are used. The default configuration is to have the light groups be opposite. However, this could cause bottlenecks if there is high volume of traffic in either direction.

The traffic simulation has been implemented using the game engine Unity. This allows researchers to tune granular parameters such as vehicle downforce, adherence to speed limits and top speed in mph. It can then run the model for a given period and export data for analysis.

The system is currently being used in a 3D virtual environment to demonstrate the feasibility of VR-based approaches to urban traffic simulation. Its main objective is to simulate a typical inner city intersection situation. This approach is particularly suited to teaching students about the design and operation of an urban traffic system.

Go Home

Leave a Reply