This project serves as a simulation to a traffic control proposal. The proposal here is that traffic control is dynamic in a way that the right of passage is given as first come first serve. Also the green light duration in each lane is dependent on the amount of traffic on that lane. In this project it is assumed that this could be implemented in reality by using object detection to detect and count vehicles on each lane and by using smart traffic lights which are connected and controlled by a master algorithm. The project is implemented using C# on the Unity game engine.
This simulation was implemented using Unity. Random cars are spawned at a random lane with a specified spawning interval time (to control the traffic flow simulation). The turn direction (forward, left and right) for each car is random. Collision detection is implemented to ensure that cars will stop behind a non-moving car. The first car in the lane will stop before the pedestrian line if the traffic light is red and will turn randomly if the light is green.
The traffic lights are dynamic. The first lane with a car reaching the stop line (pedestrian line) will be given green light depending on how many cars occupy that lane. The more the cars the more the green light (up to a thresh-hold) while other green lights display red. The digital sign next to the traffic light will display the directions that the car is allowed to turn to depending o whether there are obstructions on certain lanes (traffic jams).
When an emergency vehicle is spawned in a certain lane, all traffic lights display red except the lane of the emergency vehicle until it passes. When the EV passes, the traffic management algorithm resumes.
It was an enjoyable learning experience to implement this functionality using Unity.