Simple Traffic System allows for quick creation of waypoint based routes that can be interconnected in a modular way to create traffic routes on roads in your scenes. The primary logic is highly optimized using the new C# Job System and Burst Compiler for multi-threading, allowing you to use more of your performance budget for other content.
AI traffic logic is handled by a single AI Traffic Controller that AI Traffic Cars register to. This is a data oriented logic structure and allows the AI logic to run in parallel jobs spread across all available cores to reduce cpu usage on the main thread.
Detailed tutorial videos are available to help teach proper workflow and demonstrate available features.
New support for CiDy 2 allow 1 click traffic system generation on CiDy roads.
Key Features
No DLLs: Full source provided!
Modular: create, connect, and edit waypoint routes for AI cars to follow.
Waypoint Based: each waypoint can set speed limit, call stop driving, be a junction to new route point(s), or trigger custom events via Unity inspector.
Traffic Lights: control when AI cars can exit waypoint routes.
Yield Triggers: control when AI cars can proceed to next waypoint at intersections with traffic lights.
Traffic Stops: control when AI cars can exit waypoint routes.
Pooling System: disables cars far away from the player, and spawn cars around the player; allows scaling up scene size without using more cars.
Unity Physics Components: AI cars use Rigidbody and Wheel Colliders.
Unity Physics Components: AI cars use Rigidbody and Wheel Colliders.
Vehicle Types: define which cars can spawn/merge onto which routes.
Volume Sensors: more accurate detection compared to raycasts; uses layer mask to determine which objects should be detected.
Editor Utility Tools
Supports Undo/Redo
STS Tools Window: select from various tools to help automate waypoint route configuration tasks, reducing the need to dig through the hierarchy to configure references and settings.
Lane Connector: draws handles in the scene view over end of route waypoints, select 2 routes to auto configure lane change points.
Route Connector: draws handles in the scene view over route waypoints to create route connections between waypoints.
Route Editor: view/edit all waypoints from the selected route.
Signal Connector: draws handles in the scene view over end of route waypoints and traffic lights. Used to connect/disconnect route traffic signal lights.
Spawn Points: draws handles in the scene view over waypoints to manually add/remove spawn points, randomly assign spawn points to all waypoints, or remove spawn points from all waypoints.
Spline Route Creator: procedurally generates multiple waypoint routes and their waypoints along a spline with a unique offset for each, allowing you to quickly create routes and waypoints on large roads with curves or inclines.
Stop Connector: draws handles in the scene view over end of route waypoints and traffic stops. Used to connect/disconnect route traffic stops.
Yield Triggers: draws handles in the scene view over route waypoints, and yield triggers. Used to connect/disconnect waypoints and yield triggers.
Project Requirements
• Player Settings (Edit → Project Settings → Player)
API Compatibility Level .Net 4.x
• Package Manager Dependencies (auto installed on import)
Burst 1.4.1
Collections 0.1.1
• To use the burst compiler in standalone builds, install the Windows SDK and VC++ toolkit from the Visual Studio Installer.
Yes, route endpoints can have multiple connections to new routes, if more than 1 connection is assigned in the new route point array the new route is chosen randomly.
• Added a ‘Reverse Waypoints’ function to the AITrafficWaypointRoute; this is useful to reduce configuration time when setting up multiple parallel lanes for opposite direction.
AR:RGDK is mine, but it’s unrelated to STS so there’s no discount. AR:RGDK does include a traffic system, if you haven’t seen the tutorials are here and here; the best place to ask about these would be in the AR:RGDK thread .
STS is a more optimized traffic system using only the required logic and variables with C# Jobs and Burst Compiler for a more simple and lightweight implementation.
I got tired of digging through all the waypoint routes and their points to manually connect routes, so I made an editor window that will load all routes from scene and provide handles in scene view to help make these connections.
• Added ‘Tools > Simple Traffic System > Route Connector Window’. This draws handles in the scene view over route waypoints used to create route connections between waypoints without needing to manually select the gameobjects.
I built a spline based tool to manage configuring multiple routes and waypoints for adjacent lanes much faster and efficient. Since it’s spline based, it works well for curved roads and inclines.
This helps automates much of the layout process to reduce the amount of work required to configure traffic lanes.
• Added spine based ‘Route Creator’ to create multiple AITrafficWaypointRoutes and generate their waypoints along a spline with offset for each. This allows for fast creation of routs and points and helps reduce the amount of work required compared to manually creating each route and waypoint on the routes.
Might I suggest some asset integration scripts? Might help get more buyers for your asset.
I’m pretty sure EasyRoads and RoadArchitect provided spline points, so you can automatically get them all and place the lanes. I believe the newest 3.3 beta of EasyRoads even has full AI lane data.