Search Unity

Mobile Traffic System - City traffic for games

Discussion in 'Assets and Asset Store' started by GleyGames, Jun 5, 2021.

  1. GleyGames

    GleyGames

    Joined:
    Oct 16, 2015
    Posts:
    482
    Mobile Traffic System
    Highly performant and easy to integrate
    TrafficSystem-Cover_1950x1300.png
    Get if from: Asset Store - Mobile Traffic System
    For detailed implementation instruction see the Documentation

    Presentation video

    Demos are available to download:

    Performance test - Android
    Demo scene - Android
    Demo scene - PC

    Key features:

    • High performance - 300 cars on a 2018 Android device.
    • No coding skills required.
    • Traffic lights intersections support.
    • Priority intersections support - cars decide by themselves to wait or to enter an intersection.
    • Roundabout support - cars wait until the roundabout is free.
    • Narrow road support - cars wait until the lane is free before changing it.
    • Overtake - cars automatically overtake each other if the road has multiple lanes.
    • Building avoidance - if a car hits a building, it will try to recover itself.
    • Customizable car properties - acceleration, max speed, brake speed, steer angle etc.
    • Variable number of wheels - from 3 to as many as you want.
    • Automatically car assignments - made just by pressing a button.
    • Speed routes - set speed restrictions for some lanes or areas and all cars will follow them.
    • Car types - assign different types to cars and you can restrict access on some roads based on car types (ex: trucks are allowed only on the first lane and are not allowed inside the cities).
    • Lights support - main lights, brake lights, blinkers, reverse lights that automatically work.
    • Sound support - basic engine sound for each car based on acceleration and speed.
    • Hard shadow support - useful is you need even more performance.
    • Custom editor tools - a lot of editor windows to make the integration process as smooth as possible.
    • Simple API for advanced functionalities.
    • Parallel job system - for better performance.
    • Burst compiler - to speed up the computations.
    • No wheel colliders - raycasts are used for better performance and high accuracy.
    • Pooling system - spawns the cars around the player so you can create high density traffic with low number of used cars. Very scalable for huge environments.
    • Layer management - for better optimization.
    • Waypoints driving - it comes with an easy to use Waypoint editor, so waypoint generation is semi-automatically.
    • Full editor script that automatically prepares your car.
    • Full code is provided and fully commented, no dlls.
    • Works with any version of Unity above 2019.1.0 with any Unity license available.
    • Works with any supported Unity platforms.

    Full video tutorial playlist available on YouYube Channel


     
    Mark_01 likes this.
  2. victorkin11

    victorkin11

    Joined:
    Apr 20, 2013
    Posts:
    175
    It is possible to make AI cars respond to players' car horns or action?!
     
  3. GleyGames

    GleyGames

    Joined:
    Oct 16, 2015
    Posts:
    482
    You can override the OnCollisionEnter and OnTriggerEnter to create custom actions.
    If you provide me a full list with what actions you want I can make them on the next update.
     
    victorkin11 and Mark_01 like this.
  4. localhost

    localhost

    Joined:
    Dec 9, 2012
    Posts:
    43
    How would one go about changing the path of a specific vehicle?, Say i want to override the current path and add a offset to the current waypoint or set a new destination for example.
     
    LoneSurvivor82 likes this.
  5. victorkin11

    victorkin11

    Joined:
    Apr 20, 2013
    Posts:
    175
    I would like the system can query the car agent, replace it by user.
    Let say I want to make a firetruck sim games, the car agent not good enough to give way, so I can replace the AI agent to scripted car, do any thing I want.

    if there are API for intersection control will be great, so we can make a lot of different situation. or API can query the way point so I can make a guide line for player etc..

    I don't think any traffic system can do this in asset store, but I am looking for the best. thank!
     
  6. GleyGames

    GleyGames

    Joined:
    Oct 16, 2015
    Posts:
    482
    That is not possible at the current state of the plugin, Please send me an e-mail with your invoice number and i will note your request and soon I will make a pool with all the requests I will receive and start adding them in order of importance. thank you!
     
  7. GleyGames

    GleyGames

    Joined:
    Oct 16, 2015
    Posts:
    482
    i will consider your requests and add them in the feature list, based on user votes I will create them. thank you for your suggestion.
     
  8. victorkin11

    victorkin11

    Joined:
    Apr 20, 2013
    Posts:
    175
    How to increase the distance of special type of vehicles? That was too close. Bus.jpg
     
    Mark_01 likes this.
  9. victorkin11

    victorkin11

    Joined:
    Apr 20, 2013
    Posts:
    175
    I Fix it, after push the configuration button. but I still want to know is there anyway to custom different vehicle safe distance?

    Crop.jpg

    Also it look like there are no different mass about the vehicle size, can we add the mass for the vehicle? when the player crash in to the bus, that free very light.
     
  10. GleyGames

    GleyGames

    Joined:
    Oct 16, 2015
    Posts:
    482
    You can set the mass of the vehicle in the rigidbody component. The brake distance is 4 meters.
    Do you think that is not enough? Are you using version 1.0.3 of the plugin? I fixed some issues with braking in that version
     
    combatsheep likes this.
  11. Johnni_lam

    Johnni_lam

    Joined:
    Apr 24, 2018
    Posts:
    1
    i have a project which has been made the road and merged into the scene and building, can i just on top add this traffic system, without using the road you provided?, as the scene have one underground tunnel as well, so when i setting the car drive path, can it have the ground level up and low setting?
     
  12. GCatz

    GCatz

    Joined:
    Jul 31, 2012
    Posts:
    282
    better than cyberpunk2077
     
    combatsheep likes this.
  13. OVIOAli

    OVIOAli

    Joined:
    Dec 15, 2020
    Posts:
    6
    Is iOS supported? Android works well but I couldn't initialize the manager on iOS.
     
  14. GleyGames

    GleyGames

    Joined:
    Oct 16, 2015
    Posts:
    482
    Hello,
    i can confirm that the traffic system works on iOS. Can you give me more details about your error, or what is happening. Thank you!
     
  15. combatsheep

    combatsheep

    Joined:
    Jan 30, 2015
    Posts:
    133
    Hi,

    I am very interested in this asset and have some questions.

    1) Is it possible to dynamically reverse the direction of travel of the road instead of on Unity Editor?
    (Even though it is dynamic, I just want to change it with API etc. at the start of the Play scene)

    2) Will this asset car stop driving when a person (NPC or player) interferes with the car's progress?

    3) Do you have any plans to support the traffic of people (NPCs) including traffic lights in the future?

    Thanks.
     
  16. GleyGames

    GleyGames

    Joined:
    Oct 16, 2015
    Posts:
    482
    Hello,
    Sorry for the late replay I was not notified by Unity.
    1. No the direction cannot be changed at runtime and i do not think it will be even possible.
    2. When a car sees an obstacle it will stop. So if you mark any npc as an obstacle any traffic cars will stop.
    3. i am very busy right now, but sometimes in the future i might create some people system but it will not be included inside Traffic System because cars and people are 2 separate entities, they do not interfere and have nothing in common.
     
    combatsheep likes this.
  17. combatsheep

    combatsheep

    Joined:
    Jan 30, 2015
    Posts:
    133
    Thank you, GleyGames!
    It was very helpful. :)
     
    GleyGames likes this.
  18. colin_young

    colin_young

    Joined:
    Jun 1, 2017
    Posts:
    243
    Can this asset be used with an existing network of lanes/roads? e.g. can I set up the lanes/waypoints programmatically? I am working with EasyRoads3D and I have code that extracts the lanes into a graph, so I have all the information about the lanes as a collections of vector3. My scene has > 400 roads, so I'd really rather not have to recreate each road by hand for traffic.
     
  19. GleyGames

    GleyGames

    Joined:
    Oct 16, 2015
    Posts:
    482
    Hello,
    Currently it cannot be used, but next month I will make an update that will automatically generate waypoints from the Easy Roads 3D.
    If you are in a hurry do not buy this asset, but i the future I will add automatically integration wil all major road and city building assets from the store.
    thank you!
     
    combatsheep likes this.
  20. colin_young

    colin_young

    Joined:
    Jun 1, 2017
    Posts:
    243
    Excellent news! Will you be using the EasyRoads3D 3.3 beta to pull out the lane info that comes with that version? It has travel direction, speed and waypoints already. Raoul (the ER3D developer) is very helpful and responsive, and I'm more than happy to share what I've learned in extracting that info into a component graph (ECS/DOTS, but in the end, it's just a graph). I'm not interested in keeping my code secret or anything, especially if there is an asset that can solve the traffic problem for me without having to write it all myself :)

    I'm not in any hurry. I need to finish my roads and environment before I should be playing with traffic.
     
  21. localhost

    localhost

    Joined:
    Dec 9, 2012
    Posts:
    43
    In Unity 2021.2 beta, i often get freezes in my scene when i have this asset installed. any idea why? a message pops up and says waiting
     
  22. localhost

    localhost

    Joined:
    Dec 9, 2012
    Posts:
    43
    'Editor.Current Scene Data (Script).OnInspectorGUI'

    never had this problem before having the gleytrafficsystem in my scene. Very frustrating cause it hangs the whole editor for a few minutes.
     
  23. GleyGames

    GleyGames

    Joined:
    Oct 16, 2015
    Posts:
    482
    Hello,
    That is a problem for Unity GUI System. Please use the production versions of Unity and everything will work as intended. Thank you for understanding.
     
  24. localhost

    localhost

    Joined:
    Dec 9, 2012
    Posts:
    43
    Hi,

    Sorry i gave you the wrong error.

    'Waiting for Unity's core in UnityEditor.CoreModule.dll to finish executing' in Unity 2021.2.0b7.

    Could you please investigate, as this version will be production soon and a small thing is probably causing this issue!
     
  25. GleyGames

    GleyGames

    Joined:
    Oct 16, 2015
    Posts:
    482
    Hello,
    i will look into it, but again, I think it is an engine problem not an asset problem.
     
  26. MOhi

    MOhi

    Joined:
    Jan 29, 2014
    Posts:
    21
    Hi,
    Thanks for the great asset, I was wondering if you still working on integrating with easy roads 3D ?
    we were just thinking if it's still in progress and can be released in the next couple of weeks or if we should try to create such a system ourselves .

    Thanks
     
  27. GleyGames

    GleyGames

    Joined:
    Oct 16, 2015
    Posts:
    482
    Hello,
    The Easy Roads integration is done. Now it is in testing.
    Before release I need to do a video tutorial on how to use it. I guess that sometime next week it should be out with all instructions needed and waypoints will be automatically extracted from Easy Roads using just a click.
     
  28. colin_young

    colin_young

    Joined:
    Jun 1, 2017
    Posts:
    243
    Is that using the 3.3 beta lane data, or have you created your own lane data from the raw road data?
     
  29. GleyGames

    GleyGames

    Joined:
    Oct 16, 2015
    Posts:
    482
    I use 3.3 beta data to extract the information from easyroads.
     
    colin_young likes this.
  30. GleyGames

    GleyGames

    Joined:
    Oct 16, 2015
    Posts:
    482
    victorkin11 and colin_young like this.
  31. BettoSan

    BettoSan

    Joined:
    Dec 7, 2017
    Posts:
    57
    hello,

    Wonderful asset, but I have a few questions:

    1) I'm using the "Realistic Car Controller" from "BoneCracker Games" to control the vehicle. Is there any integration with this system?

    2) In your "Demo PC" game play, the AI is not working. If I stop in front of vehicles, they wait for you to get out. Can this be improved? Have vehicles honk, or activate a sound so we can have the NPC saying something or honking and then acting to get out of a traffic jam.


    Thanks.
     
    Last edited: Sep 16, 2021
  32. GleyGames

    GleyGames

    Joined:
    Oct 16, 2015
    Posts:
    482
    Hello,

    1. Realistic Car Controller is an asset for your player car. I do not know what is the connection between Realistic Car Controller and Mobile Traffic System, they are totally independent. You can code your player as you want with any tool you want.

    2. The AI is working as intended. Traffic cars only stop when they see you. If they will try to overtake you might create traffic jam and ruin your gameplay experience. If you want your traffic cars to honk of flash you or saying something to you that can be achieved by overriding the on trigger enter method available and there you can create any new behavior you want.
     
  33. mitis

    mitis

    Joined:
    May 21, 2013
    Posts:
    51
    Hi, I bought your asset 2 days ago, since I’ve written, I had several problems with the asset, you don’t answer me, I wrote to you by mail
     
  34. GleyGames

    GleyGames

    Joined:
    Oct 16, 2015
    Posts:
    482
    Hello,
    I can confirm that I answer to all my emails, but as it ways on the asset store page I do not work in weekend. If your email got unanswered send it again or post your question here, or join my discord server because it means I am not getting your emails for some reason.
    Thank you!
     
  35. rallethor

    rallethor

    Joined:
    Jul 30, 2015
    Posts:
    2
    Hi GleyGames,
    I bought your asset, and liking it so far :). One thing I would like to do is to manually overwrite a vehicles current action. For testing I have tried something like:
    Code (CSharp):
    1. Manager.GetVehicleList()[0].SetCurrentAction(SpecialDriveActionTypes.StopNow)
    Which I hoped would force the first vehicle to Stop, but nothing happens.

    Is there any way to manually overwrite the actions of the traffic, such that I can control the traffic through code?

    Thanks :)
     
  36. GleyGames

    GleyGames

    Joined:
    Oct 16, 2015
    Posts:
    482
    Hello,

    You ware almost right but you need to use the trigger for that because the action inside the vehicle is used just for debugging, the TrafficManager performs the actions.
    Use this event and it might work.

    AIEvents.TriggetChangeDrivingStateEvent(int vehicleIndex, SpecialDriveActionTypes action, float actionValue)

    Also this is a good suggestion, I will note it and make an API method for changing the active action.

    Thank you!
     
  37. rallethor

    rallethor

    Joined:
    Jul 30, 2015
    Posts:
    2
    Thanks for the quick response.

    The solution almost works like a charm! However, sometimes the car starts accelerating again. So for testing I have something like this:
    Code (CSharp):
    1.   private void Update() {
    2.     if(Input.GetKeyDown(KeyCode.E)) {
    3.       AIEvents.TriggetChangeDrivingStateEvent(Manager.GetVehicleList()[0].GetIndex(), SpecialDriveActionTypes.StopNow, 0);
    4.     }
    5.  
    6.     if(Input.GetKeyDown(KeyCode.Q)) {
    7.       AIEvents.TriggetChangeDrivingStateEvent(Manager.GetVehicleList()[0].GetIndex(), SpecialDriveActionTypes.Forward, 0);
    8.     }
    9.   }
    And sometimes it works fine, and the car stops when I press Q, and starts agian when I press E, but at other times the car will automatically start going Forward after I press Q (after 1 second or so). Any idea on why this happens? Does the DrivingAI emits some events or something, after I have emitted mine? :)
     
  38. GleyGames

    GleyGames

    Joined:
    Oct 16, 2015
    Posts:
    482
    Sorry for late replay! I posted a replay but it seems it was not posted.
    Change the last parameter from 0 to infinity. The stop action is designed to be use only when a car crashes, so periodically it will check and see if it can go on.
     
  39. GleyGames

    GleyGames

    Joined:
    Oct 16, 2015
    Posts:
    482
    Mobile traffic system is now compatible with CiDy 2. Try it now:


     
    heartingNinja likes this.
  40. combatsheep

    combatsheep

    Joined:
    Jan 30, 2015
    Posts:
    133
    Hi.

    I purchaced MTS and installed Burst package from MTS's UI, but got some errors...
    Code (CSharp):
    1. 'BuildTarget' does not contain a definition for 'GameCoreXboxOne'
    MTS_Burst_Error.png
    Can I fix it?

    Env:
    Unity 2019.4.20f1
    macOS BigSur 11.6
    MTS ver 1.2.0

    Thanks.
     
  41. GleyGames

    GleyGames

    Joined:
    Oct 16, 2015
    Posts:
    482
    Hello,
    Please install the burst version that is verified for your Unity version. I notice that you are not Using the latest LTS version of Unity so install the supported version of burst for it.
     
    combatsheep likes this.
  42. combatsheep

    combatsheep

    Joined:
    Jan 30, 2015
    Posts:
    133
    Thank you.
    After updating to Unity2019.4.31, the error no longer appears.:)
     
  43. BettoSan

    BettoSan

    Joined:
    Dec 7, 2017
    Posts:
    57
    In this video (
    ), in 0:14 seconds, we see a vehicle deviating from another, I assume it's the AI.
    But if I lock an intersection with my vehicle, I create a long traffic jam.
    If I put the "Obstacles" Layer on my vehicle, it looks like the other cars don't see me.
    Can you fix it? Or indicate a path.
    Thanks.
     
  44. GleyGames

    GleyGames

    Joined:
    Oct 16, 2015
    Posts:
    482
    Hello,

    In the video the car does not avoid the obstacle it simply goes back in the opposite way and then goes back in front. This behavior is intended for building avoidance. If for some reason your car sees a building after it was pushed out from the road it will go backwards in the opposite way so it will come back on the road. To replicate this you can put your obstacle in the buildings layer and you will see that behavior or you can set that behavior for obstacles to be the one designed for buildings using this method:

    GleyTrafficSystem.Manager.SetDynamicObjectInteractionDelegate(AvailableInteractions.BuildingInteraction);
     
    combatsheep likes this.
  45. BettoSan

    BettoSan

    Joined:
    Dec 7, 2017
    Posts:
    57
    Very well.
    But how can I avoid vehicle traffic jams?
    I would like to see them deviate from each other when something impedes the traffic.
     
  46. GleyGames

    GleyGames

    Joined:
    Oct 16, 2015
    Posts:
    482
    Well, now it is not possible.
    If you create your intersections properly no traffic jams will occur.
     
  47. combatsheep

    combatsheep

    Joined:
    Jan 30, 2015
    Posts:
    133
    Hi.

    Is it possible to change the number of the corresponding layer in Layer Setup?
    The Tutorial specifies that the "Traffic Layers" layer should have a User Layer of 9, but in my project I've already used number 9 so I want to set it to 19.
    However, if I change it, the collision detection of AI cars does not work and the cars will overlap.
    Probably because 9 of User Layer is selected as the layer of AI car.


    Env:
    Unity 2019.4.31f1
    macOS BigSur 11.6
    MTS ver 1.2.0

    Thanks
     

    Attached Files:

    Last edited: Oct 25, 2021
  48. Niki-4

    Niki-4

    Joined:
    Oct 29, 2017
    Posts:
    21
    Hello) Is it possible to set destination for car? I need to create car in 1 place and set their destination to another place for somekind of city sim)

    And how can I create Intersaction without 2 roads like for pedestrian walk road?)
     
    Last edited: Oct 25, 2021
  49. GleyGames

    GleyGames

    Joined:
    Oct 16, 2015
    Posts:
    482
    Hello,

    Sorry for the late reply, I was out of office.
    You can set any layer, In tutorial is 9 because it just happened. But for the spawning to work, set you car prefabs also on that layer and you should have no issue.
     
  50. GleyGames

    GleyGames

    Joined:
    Oct 16, 2015
    Posts:
    482
    Hello,

    Currently you cannot set a car destination, it will be available in the future.

    About the second question, i do not know exactly what you mean. Create 2 roads and the 3rd road leave it empty and than you pedestrians can cross. Again I do not know exactly if this is what you want. An example will be more helpful.

    Thank you!