Skip to content

RichardKarlFuchs/traffic-sim

Repository files navigation

Traffic Sim

A real-time traffic simulation modeling vehicle behaviour at intersections, built with Unity and C#.

Unity Language License


Overview

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.


Features

  • 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

Getting Started

Prerequisites

  • Unity 2020.3 LTS or newer
  • .NET / Mono (bundled with Unity)

Installation

  1. Clone the repository:

    git clone https://github.com/RichardKarlFuchs/traffic-sim.git
    cd traffic-sim
  2. Open the project in Unity Hub by selecting the cloned folder.

  3. Let Unity resolve all packages automatically (defined in Packages/).

Running the Simulation

  1. Open the main scene from the Unity Project window.
  2. Press Play in the Unity Editor.
  3. Click the "Load Simulation" button in the UI.
  4. A file picker dialog will open — select any .json save file from Assets/Saves/.
  5. The simulation starts automatically after loading.

Project Structure

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

Background

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

License

Distributed under the GNU General Public License v3.0. See LICENSE for details.

About

Traffic simulation modeling vehicle behaviour on intersections programmed in Unity

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors