A real-time traffic simulation modeling vehicle behaviour at intersections, built with Unity and C#.
Traffic Sim is a Unity-based simulation that models how vehicles behave at road intersections. It was developed as the final project for a computer science course in high school, demonstrating core concepts in simulation design, object-oriented programming, and real-time systems.
The project allows users to load pre-configured intersection layouts and observe emergent traffic patterns driven by vehicle logic and traffic signal states.
- Autonomous vehicle agents navigating intersections
- Traffic light control system
- Save/load system for simulation configurations
- Real-time simulation loop
- Interactive Unity editor and runtime interface
- Unity 2020.3 LTS or newer
- .NET / Mono (bundled with Unity)
-
Clone the repository:
git clone https://github.com/RichardKarlFuchs/traffic-sim.git cd traffic-sim -
Open the project in Unity Hub by selecting the cloned folder.
-
Let Unity resolve all packages automatically (defined in
Packages/).
- Open the main scene from the Unity Project window.
- Press Play in the Unity Editor.
- Click the "Load Simulation" button in the UI.
- A file picker dialog will open — select any
.jsonsave file fromAssets/Saves/. - The simulation starts automatically after loading.
traffic-sim/
├── Assets/
│ ├── Saves/ # Pre-built simulation configurations
│ ├── Scripts/ # C# simulation logic (vehicles, signals, etc.)
│ └── ... # Unity scenes, prefabs, materials
├── Packages/ # Unity package dependencies
├── ProjectSettings/ # Unity project configuration
└── README.md
This project was built as the final submission for a high school computer science course. The goal was to apply object-oriented design principles to a non-trivial real-world simulation — modelling how cars queue, wait, and move through signalised intersections.
Key learning outcomes:
- Designing agent-based systems in a game engine
- Managing state machines (for vehicles and traffic lights)
- Building a file-based save/load pipeline in Unity
Distributed under the GNU General Public License v3.0. See LICENSE for details.