A Unity ID allows you to buy and/or subscribe to Unity products and services, shop in the Asset Store and participate
in the Unity community.
Discussion in 'Assets and Asset Store' started by Stephen_O, Dec 15, 2019.
Version 1.0.20 is now available.
Firstly loving the package. To anyone thinking about getting it, its fantastic and I was surprised how easy it is to get it up and running.
Was looking at a different way of spawning vehicles. I want to spawn all vehicles from one end of a route at a certain rate (say 1 vehicle every 10 seconds). Was curious if anyone had done this before and any tips/ideas on how to do it.
Hi Jaime, thanks for the compliment. It always makes me feel good to hear positive feedback.
You can use this script to spawn vehicles on a specific route's spawn point every x seconds:
public class SpawnRandomFromPool : MonoBehaviour
public AITrafficSpawnPoint spawnPoint;
public bool spawnCars = true;
public float spawnRate = 10f;
private float timer;
private AITrafficWaypointRoute route;
private AITrafficCar spawnCar;
private Vector3 spawnPosition;
private Quaternion spawnRotation;
private Vector3 spawnOffset = new Vector3(0, -4, 0);
private Transform nextPoint;
private void Start()
timer = 0f;
route = GetComponent<AITrafficWaypointRoute>();
private void Update()
timer -= Time.deltaTime;
if (timer <= 0f)
timer = spawnRate;
spawnCar = AITrafficController.Instance.GetCarFromPool(route);
if (spawnCar != null && spawnPoint.isTrigger == false)
spawnPosition = spawnPoint.transform.position + spawnOffset;
spawnRotation = spawnPoint.transform.rotation;
nextPoint = spawnPoint.waypoint.onReachWaypointSettings.nextPointInRoute.transform;
Just attach it to the AITrafficWaypointRoute you want to use, and assign an AITrafficSpawnPoint from the route. Then make sure pooling is enabled (it only needs to be enabled at startup, you can disable it after traffic has spawned if this is your only spawn point), there needs to be enough cars in the pool for new cars to spawn.
Wow....thank you so much Stephen, I just tried it out and it works like an absolute charm!!!
Thank you for making such an incredible tool!
and thank you also for getting back to me....excellent customer support!
Thank you so much for being so amazing!!!
hey, i‘m using version 1.0.20, i think there is a bug here.
I wanna spawn vehicles from pool, so i checked "Random spawn from pool", and left "spawnTrafficVehicles" empty, then I hit the play button, some errors was threw in console,and no car was spawned.
here is the screenshot.
That option on waypoint routes should be renamed to "Spawn From AITrafficController".
For it to work, you need to populate the 'Traffic Prefabs' array on the AITrafficController. It will spawn car prefabs from the AITrafficController array instead of the waypoint route array.
If you want to use the pooling system, populate the 'Traffic Prefabs' array, enable 'Use Pooling', and assign the 'Centert Point' on the AITrafficController.
Sorry about the confusion, it will be renamed next update.
I know what's going on here.
I thought AITrafficWaypointRoute.SpawnTrafficVehicles is the prefabs to be spawned on this route, so I figured if I want to use the prefabs on AITrafficController, i just need to 1.leave this array empty and 2.check the 'randomSpawnFromPool'.
but I was wrong, i have to set that array size to a non-zero number.
Thanks for the feedback, I'll try to make that setting more intuitive as well.
I am very interested in this asset.Can i use it in my project which is generating road at runtime procedually?like an endless racing game in a scene with endless straight roads and crossings.
hello, how to set the parent of all spawned vehicles?
I think it would be possible, though you'd obviously have to do some custom scripting to make it work as needed, I believe the API should be able to handle the following scenario:
The AITrafficController caches all the routes and spawn points when it initializes, so those would need to be present i n your scene when it starts. One possible solution would be to create preconfigured route segments, enough to satisfy your custom pooling need. You'll have to script a system that would move around these cached segments and update the waypoint settings on each to connect to neighbors when placing them procedurally during runtime. You may also have to custom script moving the cars around as needed for the segments.
U̶n̶f̶o̶r̶t̶u̶n̶a̶t̶e̶l̶y̶ ̶s̶e̶t̶t̶i̶n̶g̶ ̶a̶ ̶p̶a̶r̶e̶n̶t̶ ̶f̶o̶r̶ ̶t̶h̶e̶ ̶c̶a̶r̶s̶ ̶i̶s̶ ̶n̶o̶t̶ ̶s̶u̶p̶p̶o̶r̶t̶e̶d̶ ̶a̶t̶ ̶t̶h̶i̶s̶ ̶t̶i̶m̶e̶,̶ ̶i̶f̶ ̶t̶h̶i̶s̶ ̶i̶s̶ ̶s̶o̶m̶e̶t̶h̶i̶n̶g̶ ̶t̶h̶a̶t̶'̶s̶ ̶i̶m̶p̶o̶r̶t̶a̶n̶t̶ ̶t̶o̶ ̶y̶o̶u̶ ̶l̶e̶t̶ ̶m̶e̶ ̶k̶n̶o̶w̶ ̶a̶n̶d̶ ̶I̶ ̶c̶a̶n̶ ̶t̶r̶y̶ ̶t̶o̶ ̶w̶o̶r̶k̶ ̶o̶n̶ ̶a̶ ̶s̶o̶l̶u̶t̶i̶o̶n̶.̶
I've found a solution, will be added next update.
I've made some modifications, it's now possible to set a parent via toggle in the AITrafficController inspector. If the parent transform is not defined, the AITrafficController transform will be the parent.
I'll submit this soon as update v1.0.21
Version 1.0.21 submitted
• Added AITrafficController.GetCarFromPool(AITrafficWaypointRoute, AITrafficVehicleType) method, this alternate method allows you to specify the type of car returned from the pool.
• Added 'Set Car Parent' option to AITrafficController - NOTE: having the car objects under a parent will result in reduced perfiormance, this setting is only recommended for reducing hierarchy clutter with in editor testing.
• Renamed AITrafficWaypointRoute.randomSpawnFromPool variable to spawnFromAITrafficController to better describe what it does. Updated tooltip description to be more clear on how it works.
Version 1.0.22 is now available.
great! thanks a lot!
New tutorial for using a player car with STS:
Version 1.0.22 is almost ready. With this update I've spent some time refactoring the variables and register logic to improve runtime API features. This update primarily allows spawning and registering new cars dynamically at runtime, as well as enabling/disabling AI processing on any car to allow for more customization. I'll be adding 2 new example scripts to demonstrate usage in the Scripts/Utility folder.
Toggle Car AI Processing Example
public class ToggleCarAIProcessing : MonoBehaviour
public AITrafficCar car;
public AITrafficWaypoint targetWaypoint;
public void DisableAIProcessing()
public void EnableAIProcessing()
Spawn And Register Car At Runtime Example
public class RegisterCarRuntime : MonoBehaviour
public AITrafficCar aITrafficCarPrefab;
public AITrafficWaypointRoute aITrafficWaypointRoute;
public AITrafficSpawnPoint aITrafficSpawnPoint;
private AITrafficCar spawnedAITrafficCar;
public void SpawnAndRegisterCar()
if (aITrafficSpawnPoint.isTrigger == false)
spawnedAITrafficCar = Instantiate(aITrafficCarPrefab.gameObject, aITrafficSpawnPoint.transform.position, aITrafficSpawnPoint.transform.rotation).GetComponent<AITrafficCar>();
Version 1.0.22 submitted
Collections is now required to be installed via the Package Manager
• AITrafficController private data refactor; NatvieArrays were converted to NativeLists to better support adding new cars at runtime.
• AITrafficCar.RegisterCar can now be called at runtime to support dynamically adding traffic cars
• New function AITrafficCar.DisableAIProcessing
• New function AITrafficCar.EnableAIProcessing
• AITrafficCar an now be a child of other objects
• Added 'Set Car Parent' option to AITrafficController, allowing you to define a transform as a parent or use the AITrafficController as a parent if undefined. Please note that having the car objects under a parent will result in reduced performance, this setting is only recommended for reducing hierarchy clutter with in editor testing.
Hi Stephen, I am on the latest version of Unity 2019.4.9 and I can't place any waypoints on a plane with a collider. I added the AITrafficController and AITrafficWaypointRoute. I have the AITrafficWaypointRoute selected and then try to hit Shift + Left Click to add waypoints and all it does is (add) select the plane. What am I doing wrong. I followed your intro tutorial exactly the same. I am hoping to add waypoint onto a terrain eventually. I should be able to do this no?
Stephen helped me solve this issue on Discord. I had to go to Window - layouts - reset factory default and now it works...
Unfortunately this is a long standing Unity bug, that's never been fixed, and resolving it is only passed on through tribal knowledge. I've seen this happen in so many projects that I've lost count.
Anytime an editor window or tool function does not work as expected, resetting the unity window layout to default will often fix the editor related bugs.
Version 1.0.22 is now available.
Note: Collections is now required to be installed via package manager.
Version 1.0.23 submitted
• Added stopTime variable to AITrafficWaypointSettings. Set stop time greater than 0 to restart the car after the stop time duration.
Version 1.0.23 is now available.
Collections is nowhere to be found in the package manager in the latest Unity releases now, rendering this resource inoperable. What do we do??
Unity has been making some package related changes in the latest beta/tech release streams for 2020. Personally I've been hoping they would make it easier to use packages, not harder. My hope is that these packages are eventually auto installed.
I recently made a recommended setup guide for current LTS, and will make a new one when 2020 LTS is available.
2019 LTS Guide:
For current 2020 versions, you'll need to do the following to import collections or any other unlisted packages:
1. Edit > Project Settings > Package Manager
2. Toggle on Enable Preview Packages
3. Click I understand Popup
4. Window > Package Manager
5. Click the drop-down menu (plus icon) on the top left of the window, and select add package from git URL…
6. Enter: com.unity.collections
7. Click Add
Version 1.0.24 has been submitted.
• Brake lights are now enabled when StopDriving is called.
• StopDriving no longer sets car rigidbody to isKinematic.
• Wheel processing is no longer disabled while the car is stopped.
Version 1.0.24 is now available.
Version 1.0.25 submitted.
• Removed Resources folder, moved contents to Prefabs/Primary
• Editor functions logic refactor to remove needing to use Resources.Load
• Removed static class LaneChangeHelper, function was moved to Editor_STSWindow where it's used.
how to install Collections (0.1.1) , im using mac UNITY
Enable show preview packages in the package manager to see it, you can use any version of collections. There are more details in this post: https://forum.unity.com/threads/simple-traffic-system.794268/page-6#post-6318243
Version 1.0.25 is now available.
Version 1.0.26 submitted.
• Moved acceleration power setting from AITrafficController to AITrafficCar, AITrafficController can now have unique values for each car, values are set when car is registered.
BuildFailedException: Burst compiler (1.3.6) failed running.
when I try to build and save the application it's giving me this error
I'm using MAC
To use burst in on mac builds, you'll need to install the following:
Xcode with command line tools installed (xcode-select --install)
From Unity Docs: https://docs.unity3d.com/Packagesfirstname.lastname@example.org/manual/index.html#standalone-player-support
Each platform you target will have different build requirements.
A new tutorial for stylized vehicles pack integration to match settings for current version.
i installed xcode-select --install
but still getting this error
/bin/sh: /Users/randomUser/Library/PackageCacheemail@example.com/.Runtime/hostlin/lld: cannot execute binary file
Burst.Compiler.IL.Aot.AotLinkerException: The native link step failed. Check previous exception in the log - linker command line : "/Users/RandomUser/Library/PackageCachefirstname.lastname@example.org/.Runtime/hostlin/lld -flavor darwin -arch x86_64 -macosx_version_min 10.8 -sdk_version 10.9 -r -dylib -o "/Users/maybankpro2017/PakYouWorld/Suyop/Temp/Burst/burst-aotu0k9c1zm.dsk/lib_burst_generated.bundle" "/Users/maybankpro2017/PakYouWorld/Suyop/Library/PackageCacheemail@example.com/.Runtime/libs/burstRTL_m64.a" "/Users/maybankpro2017/PakYouWorld/Suyop/Temp/Burst/burst-aotu0k9c1zm.dsk/lib_burst_generated_part_1.o" "/Users/maybankpro2017/PakYouWorld/Suyop/Temp/Burst/burst-aotu0k9c1zm.dsk/lib_burst_generated_part_3.o" "/Users/maybankpro2017/PakYouWorld/Suyop/Temp/Burst/burst-aotu0k9c1zm.dsk/lib_burst_generated_part_2.o" "/Users/maybankpro2017/PakYouWorld/Suyop/Temp/Burst/burst-aotu0k9c1zm.dsk/lib_burst_generated_part_0.o" "/Users/maybankpro2017/PakYouWorld/Suyop/Temp/Burst/burst-aotu0k9c1zm.dsk/lib_burst_generated_part_5.o" "/Users/maybankpro2017/PakYouWorld/Suyop/Temp/Burst/burst-aotu0k9c1zm.dsk/lib_burst_generated_part_7.o" "/Users/maybankpro2017/PakYouWorld/Suyop/Temp/Burst/burst-aotu0k9c1zm.dsk/lib_burst_generated_part_6.o" "/Users/maybankpro2017/PakYouWorld/Suyop/Temp/Burst/burst-aotu0k9c1zm.dsk/lib_burst_generated_part_4.o" "/Users/maybankpro2017/PakYouWorld/Suyop/Temp/Burst/burst-aotu0k9c1zm.dsk/lib_burst_generated_part_1_merged.o""
at Burst.Compiler.IL.Aot.AotNativeLinkBase.RunNativeLinkerTool (System.String command, System.String arguments, System.String errorMessage, System.String commandType, System.String workingDirectory, System.Boolean muteOutputs) [0x000d0] in <9b99a8d26a5f43d4ad1097789969a537>:0
at Burst.Compiler.IL.Aot.AotNativeLinkLLVMMacOS.Link (Burst.Backend.TargetCpu targetCpu, System.Collections.Generic.List`1[T] inputFiles, System.String outputFile, System.Boolean enableDebugInfo) [0x00118] in <9b99a8d26a5f43d4ad1097789969a537>:0
at Burst.Compiler.IL.Aot.AotCompiler.Link (System.Collections.Generic.List`1[T] groups, System.String nameSuffix, Burst.Compiler.IL.Aot.AotCompilerOptions compilerOptions, System.IO.TextWriter consoleOut, System.IO.TextWriter consoleError) [0x001f8] in <9b99a8d26a5f43d4ad1097789969a537>:0
at Burst.Bcl.BclApp+LibraryThread.Process (Burst.Bcl.BclApp+LibraryCompilationRequest libraryRequest) [0x00440] in <52cdf9e3a3c345ba8ab16cad75b48614>:0
at Burst.Bcl.BclApp+LibraryThread.Run () [0x0001a] in <52cdf9e3a3c345ba8ab16cad75b48614>:0
at System.Threading.ThreadHelper.ThreadStart_Context (System.Object state) [0x00014] in <fb001e01371b4adca20013e0ac763896>:0
at System.Threading.ExecutionContext.RunInternal (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) [0x00071] in <fb001e01371b4adca20013e0ac763896>:0
at System.Threading.ExecutionContext.Run (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) [0x00000] in <fb001e01371b4adca20013e0ac763896>:0
at System.Threading.ExecutionContext.Run (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state) [0x0002b] in <fb001e01371b4adca20013e0ac763896>:0
at System.Threading.ThreadHelper.ThreadStart () [0x00008] in <fb001e01371b4adca20013e0ac763896>:0
Version 1.0.26 is now available.
It sounds like there's some issue with building burst on a mac. Since Unity is building and maintaining the burst compiler you'd likely have better luck asking in their Burst for standalone players forum thread.
Version 1.0.27 submitted.
• Fixed inspector script error for AITrafficController Car Settings
Version 1.0.27 is now available.
It usually works well, but when the following error occurs, all cars lose control.
The error occurs 50-200 times at once and then again after a while. I can't figure out what causing it.
I use pooling, traffic lights, and yield triggers (without traffic lights).
NullReferenceException: Object reference not set to an instance of an object.
TurnTheGameOn.SimpleTrafficSystem.AITrafficController.FixedUpdate () (at Assets/TurnTheGameOn/SimpleTrafficSystem/Scripts/AITrafficController.cs:621)
Also, if the car's max speed is higher than speed limit on the route, the brake lights flashing continuously.
Sorry for my bad english.
Hello, it looks like your errors/bugs are related to how you're using YieldTriggers, they're designed to be used with traffic lights (you can not use them without a traffic light).
I do mention this in the YieldTriggers tutorial video, If you want to use YieldTriggers, please follow the tutorial video for more details on their setup and usage:
I would suspect that using the YieldTriggers on routes without traffic lights is what's causing your cars to behave strangely. Also, the error is specifically is pointing to a waypoint with an empty YieldTriggers array field, you should check to make sure there are no empty YieldTrigger fields on your waypoints.
Version 1.0.28 has been submitted.
• Improved AITrafficWaypointRoute inspector.
• AITrafficWaypointRoute 'Spawn From AITrafficController' option now reveals a 'Spawn Amount' value, used to define how many cars to spawn from AITrafficController prefab list. This will prevent user error from ambiguity when using this setting.
Thanks for your answer, I'll rework it with traffic lights.
The yield triggers usually works great even without lights, but sometimes this error occurs. So the error is not permanent, it caused by some event. Unfortunately, I couldn't figure it out. Maybe it has to do with the fact that OnTriggerExit doesn't run on cars going back to the pool?
The error is pointing to a waypoint with an empty YieldTriggers array field, check to make sure there are no empty YieldTrigger array fields on your waypoints (if you have an unassigned YieldTrigger field it will cause an error).
Version 1.0.28 is now available.
This 2 errors appears when I want to make a build:
(Unity 2019.4.8f1, Burst 3.6.1, Collection 0.9.0)
Assets\TurnTheGameOn\SimpleTrafficSystem\Scripts\AITrafficWaypointRouteCreator.cs(194,69): error CS1061: 'AITrafficWaypointRoute' does not contain a definition for 'ClickToSpawnNextWaypoint' and no accessible extension method 'ClickToSpawnNextWaypoint' accepting a first argument of type 'AITrafficWaypointRoute' could be found (are you missing a using directive or an assembly reference?)
Assets\TurnTheGameOn\SimpleTrafficSystem\Scripts\AITrafficWaypointRouteCreator.cs(199,70): error CS1061: 'AITrafficWaypointRoute' does not contain a definition for 'ClickToSpawnNextWaypoint' and no accessible extension method 'ClickToSpawnNextWaypoint' accepting a first argument of type 'AITrafficWaypointRoute' could be found (are you missing a using directive or an assembly reference?)
Those bugs were fixed a few months ago in an older version. I'm unable to reproduce this error when building with the latest version of the asset and same project setup as you.