Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Join us on Thursday, June 8, for a Q&A with Unity's Content Pipeline group here on the forum, and on the Unity Discord, and discuss topics around Content Build, Import Workflows, Asset Database, and Addressables!
    Dismiss Notice

Simple Traffic System

Discussion in 'Assets and Asset Store' started by Stephen_O, Dec 15, 2019.

  1. Stephen_O

    Stephen_O

    Joined:
    Jun 8, 2013
    Posts:
    1,505
    Version 1.0.29 submitted.

    • Added Arrow Gizmo Scale option to STS Preferences window.
     
  2. Konyak

    Konyak

    Joined:
    Nov 21, 2019
    Posts:
    20
    I always updated when a new version came out.
    Apparently there may have been a problem in unity when updating the asset, because as soon as I completely deleted and re-imported, it already works.
    Sorry for my mistake.
     
    Stephen_O likes this.
  3. Stephen_O

    Stephen_O

    Joined:
    Jun 8, 2013
    Posts:
    1,505
    Great, I'm glad it's working now.
     
  4. Stephen_O

    Stephen_O

    Joined:
    Jun 8, 2013
    Posts:
    1,505
    Version 1.0.29 has been resubmitted.

    • Added Arrow Gizmo Scale option to STS Preferences window.
    • Now using 'Include Package Manager Dependencies' as per asset store guidelines.

    I've never used the recently added 'Include Package Manager Dependencies' for reasons related to ambiguity, and not wanting to force project level changes on a user without their knowledge, but 1.0.29 was declined due to not using it, it's now required in the updated publisher guidelines. Now it's enabled for STS, and should automatically install correct package dependencies on import to a project. I will be hopeful that there are no unintended side effects related to this change, the best case scenario is that this will just work as intended without any side effects. I do however recommend using version control and at least backup your package manager file before importing any Unity asset that includes dependencies to be sure you can revert if something does break.
     
  5. scorpionfeast

    scorpionfeast

    Joined:
    Dec 5, 2014
    Posts:
    18
    For some reason, Its not working properly, When I use Shift + Left click, it donot add waypoint, Can you help?
     
  6. Stephen_O

    Stephen_O

    Joined:
    Jun 8, 2013
    Posts:
    1,505
    Often resetting the unity window layout to default (top right corner of Unity Editor) will fix editor related bugs. Unfortunately this is an unresolved Unity bug that has been around for a long time.
     
  7. Stephen_O

    Stephen_O

    Joined:
    Jun 8, 2013
    Posts:
    1,505
    Version 1.0.29 is now available.
     
  8. Stephen_O

    Stephen_O

    Joined:
    Jun 8, 2013
    Posts:
    1,505
    Version 1.0.30 submitted.

    • Improved EngineSound script so that it can be added without any setup required.
     
  9. AGregori

    AGregori

    Joined:
    Dec 11, 2014
    Posts:
    514
    Hi there. When I update Simple Traffic to the latest, it flat out deletes my unity-packagemanager-ui from the setup, which of course renders the system unstable. (I have to manually edit manifest.json to save the project, but no user is supposed to do that.)
    What am I doing wrong?
     
    Last edited: Oct 8, 2020
  10. Stephen_O

    Stephen_O

    Joined:
    Jun 8, 2013
    Posts:
    1,505
    I am sorry this is happening.

    I agree with you 100%, this is not desired behavior, and should not happen.

    To be clear, I was forced by Unity to include dependencies the way they are now setup. Unity recently declined my asset update for this reason:

    Assets with dependencies from Package Manager should include the necessary packages for the asset to work. Use the “Include Dependencies” feature in the Asset Store Tools to include the packages. There are errors related to packages in the console once the asset is imported - please make sure all necessary packages are included as dependencies. ( https://unity3d.com/asset-store/sell-assets/submission-guidelines , Section 1.2.g)


    The problem is, Unity does not allow me to specify which packages are dependencies, it takes them all. Which is a well known issue documented months ago in the publisher forum. I raised a concern in the publisher forum thread about this topic last week when Unity declined my update: https://forum.unity.com/threads/ass...ld-package-manager-ui-as-a-dependency.925910/

    Unity needs to allow publishers to specify dependencies, and not take everything; this is what's causing the manifest bug. Until Unity can give publishers a proper option to dependencies, I suspect we're in limbo.

    I'm still waiting for a reply from Unity Asset Store Team, I also submitted a ticket to Unity Support: ticket #924424

    My hope is Unity provides publishers with a proper solution to this issue.

    Hello,
    I've recently had an update to my asset declined.
    This is the asset store reply:
    Assets with dependencies from Package Manager should include the necessary packages for the asset to work. Use the “Include Dependencies” feature in the Asset Store Tools to include the packages. There are errors related to packages in the console once the asset is imported - please make sure all necessary packages are included as dependencies. ( https://unity3d.com/asset-store/sell-assets/submission-guidelines , Section 1.2.g)
    There's a publisher forum thread about this issue: https://forum.unity.com/threads/ass...ld-package-manager-ui-as-a-dependency.925910/
    As expected (because it's a known issue), this forced asset update is causing errors for customers when importing into their current project.
    I'm unable to get a response from Unity Asset Store team about how to proceed, it appears I'm the only publisher currently being forced to do this based on other publisher replies.
    QUOTE="AGregori, post: 6396233, member: 734580"]
    Hi there. When I update Simple Traffic to the latest, it flat out deletes my unity-packagemanager-ui from the setup, which of course renders the system unstable. (I have to manually edit manifest.json to save the project, but no user is supposed to do that.)
    What am I doing wrong?
    [/QUOTE]
    Can Unity please assist me?
    I previously had the setup process defined in my package description, in documentation, and a tutorial video in the description. This is my 30th update to the asset since releasing it this year, but first time not including package dependencies caused it to be rejected.
    We should be able to manually define which package dependencies will be included. As a user, how many unwanted/unnecessary packages will now be imported from other assets across the board that when they check this box? Unintentionally installing unwanted packages will likely cause grief for end users.
    Personally, I wish I had the ability to test import it myself to see what happens, and some documentation providing insight to this option on a technical level would help. Testing is a huge part of development. Something like this should be rolled out a bit more gracefully, be testable by publishers, and with more information provided to publishers that would facilitate a smooth transition. In this case, I can't test it until it's live on the store.
    Is everyone now forced to do this or am I the only one? If it's just me, which is how it seems since I updated the asset Friday without any problems, why now, and why not force everyone else to make the same update?
    Thank you.
    Best regards,
    Stephen
     
    AGregori likes this.
  11. AGregori

    AGregori

    Joined:
    Dec 11, 2014
    Posts:
    514
    Thank you for a detailed explanation of the bug. It's worse than I thought because manifest nulls registry items when it happens, so post-processing etc. need to be reinstalled.
    Let's hope for a solution soon.
     
  12. Stephen_O

    Stephen_O

    Joined:
    Jun 8, 2013
    Posts:
    1,505
    Thanks for some more info, I'll add it in the publisher forum thread.

    The frustrating part is no one from Unity staff has responded since inquiring in the publisher thread over 10 days ago, and my last customer service ticket took 16 days for someone to look at.
     
  13. Stephen_O

    Stephen_O

    Joined:
    Jun 8, 2013
    Posts:
    1,505
    Version 1.0.31 submitted.

    • Attempt new submission to avoid package dependency bug (support ticket #924424), manually editing json package manifest file to omit default project packages and package manager UI.

    -

    I have not heard from anyone about this issue, anytime I reach out to Unity I'm often ignored like this situation (I've been asking for help in the publisher forum since late September), this is a bit frustrating to work through as only Unity can provide the guidance required.

    Knowing my asset is currently breaking user projects for the last couple weeks if using the import dependencies option, I'm going to attempt to resubmit making guesses. I hope this does not cause additional unexpected consequences, but I need to not have everyone that imports my asset experience the current issues package issues documented in the last few posts.

    I have been discouraged from doing anything with this asset due to not knowing what to do, and Unity not providing any assistance or insight.

    My test this time will be to manually remove all dependencies from my json packages manifest, previously I only removed all entries from the package manager, but the manifest still contained all the built in references that I believe are causing the issues. Note: I get project errors when doing this, my actual asset project is now unusable and I will need to manually revert when done if I still want to use the project.

    I really don't think this is a good practice, and truly hope someone from Unity staff will step in to provide insight that helps resolve these package manager dependency issues, or provide a publishing guide that will not cause errors when a users imports the package or a publisher is trying to upload.
     
    AGregori likes this.
  14. AGregori

    AGregori

    Joined:
    Dec 11, 2014
    Posts:
    514
    Thanks for the update. I for one was forced to delete your asset till you give the A-OK again, since with the dependencies bug it would create a goatf*** in my project, pardon my French. ;)
     
  15. Stephen_O

    Stephen_O

    Joined:
    Jun 8, 2013
    Posts:
    1,505
    Version 1.0.31 is now available.

    My latest test seems to be working as intended, meaning my asset is no longer impacting installed packages on import. When I submitted, I manually edited my project's manifest.json file, removing every package except what is required by STS.

    These should be the only modified packages.

    Code (CSharp):
    1. {
    2.   "dependencies": {
    3.     "com.unity.burst": "1.3.8",
    4.     "com.unity.collections": "0.1.1-preview"
    5.   }
    6. }
    Heads up to you and anyone else reading. Even though I have solved this for STS, many other publishers, and even Unity, are unaware of the proper submission process; so this will likely start happening with other assets where Unity Asset Store team is asking publishers to include dependencies before updates can be approved. Unity never responded to my support request or inquiries on the publisher forum.
     
    AGregori likes this.
  16. Stephen_O

    Stephen_O

    Joined:
    Jun 8, 2013
    Posts:
    1,505
    Version 1.0.32 submitted.

    • Added AITrafficController.GetTrafficCars method, returns an AITrafficCar array of registered cars.
    • Added centerOfMass script to utility folder. Attach this component to an AITrafficCar, defines a custom rigidbody center of mass position.
     
  17. Stephen_O

    Stephen_O

    Joined:
    Jun 8, 2013
    Posts:
    1,505
    Version 1.0.32 is now available.
     
  18. Stephen_O

    Stephen_O

    Joined:
    Jun 8, 2013
    Posts:
    1,505
    Version 1.0.33 submitted.

    • Moved 'STS Tools Handle Customization Options' to Preferences menu.
    • Updated Burst dependency to 1.3.9
     
  19. Stephen_O

    Stephen_O

    Joined:
    Jun 8, 2013
    Posts:
    1,505
    Version 1.0.33 is now available.
     
  20. Stephen_O

    Stephen_O

    Joined:
    Jun 8, 2013
    Posts:
    1,505
    Version 1.0.34 submitted.

    • Added 2 new methods for updating the car's top speed
    AITrafficCar.SetTopSpeed(float speed)
    AITrafficController.SetTopSpeed(int index, float value)
    • Added 2 new methods for instructing AI cars to lane change when able
    AITrafficCar.SetForceLaneChange(bool value)
    AITrafficController.SetForceLaneChange(int index, bool _alue)
    • Added PlayerTriggerLaneChange utility script and prefab, uses a trigger detecting a tag to instruct the car to change lanes when able.
    • Changed AITrafficCar prefab tag from Player to Unassigned
     
  21. Stephen_O

    Stephen_O

    Joined:
    Jun 8, 2013
    Posts:
    1,505
    Version 1.0.34 is now available.
     
  22. Stephen_O

    Stephen_O

    Joined:
    Jun 8, 2013
    Posts:
    1,505
    Version 1.0.35 submitted.

    • Added RandomSpeedFluctuation utility script that can be attached to traffic car prefabs to set a random speed between a specified min/max every x seconds.
     
    jangomoose likes this.
  23. Stephen_O

    Stephen_O

    Joined:
    Jun 8, 2013
    Posts:
    1,505
    Version 1.0.35 is now available.
     
  24. masternully

    masternully

    Joined:
    Dec 22, 2018
    Posts:
    13
    Why do cars behave so strangely at the connection, and do not drive along a clearly defined trajectory?
    And also, they are flying.
     
  25. Stephen_O

    Stephen_O

    Joined:
    Jun 8, 2013
    Posts:
    1,505
    You need to adjust the speed limit on the waypoints to make sure the car is traveling slow enough to not overshoot the target.

    Check your ground surface colliders, there must be something they are driving on.
     
  26. Stephen_O

    Stephen_O

    Joined:
    Jun 8, 2013
    Posts:
    1,505
    Version 1.0.36 submitted.

    • Improved how the first car at a red light will stop; the car will now smooth into a stop over time instead of stopping immediately.
    • Fixed a bug where front wheels would jitter while stopped.
    • Adjusted timing and grouping of southern intersection lights in demo scene foe better traffic flow.
    • Adjusted front sensor transform position on car prefabs to behind collider bounds, ensuring detection is always happening.
    • Added zero friction physics material to car prefabs, prevents sticking together after collision.
     
  27. Stephen_O

    Stephen_O

    Joined:
    Jun 8, 2013
    Posts:
    1,505
    Version 1.0.36 is now available.
     
  28. DromoDesigner

    DromoDesigner

    Joined:
    Mar 27, 2016
    Posts:
    72
    Hello, I am building a city builder game similar in style to SimCity, where the player will place roads on a map. The simulated population will drive cars on the newly placed roads between specific points, such as their house to their place of work.

    Would it be possible to use this Simple Traffic System asset to achieve this?

    Thank you for your help.
     
    Stephen_O likes this.
  29. Stephen_O

    Stephen_O

    Joined:
    Jun 8, 2013
    Posts:
    1,505
    Hello, in theory, this should be possible, but might need some minor adjustments. There's a fairly robust API that was used to create all the editor tools, and various utility functions; here's a link. Also, please check the tutorial videos.

    The way I would approach it is to use the pooling system, but make the pool area large enough so cars never despawn, instead you would manually control when they spawn and return to the pool by your own game systems through scripting API calls.

    You would also need to script a way to spawn and connect the routes you create on new roads, this is already exposed in the API. I'm pretty sure I would need to create a method and adjust some logic for you to be able to register new routes with the AITrafficController at runtime. Now that you mention it, I will add this method. If you decide to buy and need the update sooner, or have any other questions, let me know.

    *Edit*
    There is not currently a way to do point to point navigation, which may be a requirement for you. A work around might be to have dedicated routes for cars that are not connected to others and only lead to the destinations.
     
    Last edited: Nov 13, 2020
  30. DromoDesigner

    DromoDesigner

    Joined:
    Mar 27, 2016
    Posts:
    72
    Hello, thank you for your detailed response - appreciate it!

    This is a great looking system, with very good reviews, so I would really like to use it in my project. However, I do need a point to point navigation system for vehicles (e.g. a truck spawns by a factory, and takes its cargo to a shop elsewhere in the city).

    How tricky would it be to implement the solution for dedicated routes that you mention? Would it have a big performance hit if that was used for a lot of cars (I imagine that there could be about 500 cars max in the city on the roads, but only a fraction of these would need to be rendered on screen at any one time).
     
  31. Stephen_O

    Stephen_O

    Joined:
    Jun 8, 2013
    Posts:
    1,505
    It sounds like you require something that STS does not provide. Unfortunately this is something that's not currently available or in development, if it is a necessity, it might be better to find an alternative system that includes all of the features you need.

    First off, this is all theory crafting, I imagine it would require a lot of specific procedural code. I've personally never created a city builder game, and would likely design exactly what I need if I were to do so, iterating on logic as I go if needed, likely using a pathfinding solution to reduce complexity and need for extra overlapping routes.

    If it's unclear, it might be more work than what you're prepared for, ultimately meaning you might not be able to achieve what you want with STS. This can depend on many factors, and will be impossible for me to accurately answer. It's not a proper evaluation for me when I really have no real context of your project, scope, resources, target platforms, scripting experience, etc.

    When I say dedicated routes, I mean creating a route from point a to point b for each of your start/end destinations (perhaps multiple connected routes if you need to add traffic lights for intersections in between a and b). I would recommend watching the tutorials to see how everything works in editor, as this would be what you would be automating through custom scripting in your game code; I imagine you would need to custom script almost all of what you would be doing with STS for a city builder game since the scene would be empty by default. Generally speaking though, you would be doing tutorials 1-3 for each of your a to b routes, placing the points procedurally as needed. None of these routes would be connected to other a/b routes and eliminate the need for pathfinding.

    With source code provided, you can also edit out, or customize some of the STS logic processing where it may not be needed to maximize performance, or build up what you do need. An example would be if the car wheels are never visible, you can edit out the wheel mesh transform updates to reduce unnecessary logic processing. Not sure how comfortable you are with modifying a codebase to do something like that.

    I also assume you won't need to use side sensors for detecting other cars while lane changing, so that's something you can turn off via inspector that is on in the demos (it will save the cost of 2 box casts per car, per frame, much more costly than OnTriggerEnter callbacks from waypoint trigger collisions).

    I won't be able to provide an accurate answer without actually building your simulation and testing it, after which there would be an optimization phase to restructure, and better control anything that could be causing issues. There is a small performance cost when a car collider hits a waypoint and OnTriggerEnter is called, having overlapping waypoints would increase this cost. As a note, there are 130 routes in the demo scene with about 1850 waypoints.
     
  32. ZolnierGames

    ZolnierGames

    Joined:
    Feb 19, 2018
    Posts:
    87
    I'm playing around with the update and trying to tweak my code a bit. Is there a way to loop through all of the spawned cars and remove them so that the TrafficController respawns them again? When I load parts of my city and enable or disable certain waypoint groups, it often messes up the cars that are on left on the scene already. Should I just return all to the pool or can I delete all instantiated cars and then let the traffic controller just respawn them?
     
  33. ZolnierGames

    ZolnierGames

    Joined:
    Feb 19, 2018
    Posts:
    87
    So, what I'm learning is that I can easily use the MoveAllCarsToPool() function to clear all cars, but when I enable a different set of waypoints based on reloading parts of a level, when the cars respawn, they still try to go to the old waypoints, even if they are disabled. Is there a way to reset/clear the waypoint that a car is driving toward when I call MoveAllCarsToPool() so when they respawn, they are driving toward the proper waypoint?
     
  34. amynox

    amynox

    Joined:
    Oct 23, 2016
    Posts:
    166
    Hi All,

    This asset look really impressive. Was just wondering :
    1/ Can it be used to "simulate" pedestrians walking on sidewalks ?
    2/ If no, can you please recommand "compatible" asset with this one for pedestrians simulation ?

    Thanks
     
  35. ZolnierGames

    ZolnierGames

    Joined:
    Feb 19, 2018
    Posts:
    87
    I don't see why not. If you moved your waypoints from the street to the sidewalks, you can have your "cars" array be people instead of vehicles and I would imagine they could go from waypoint to waypoint just like a car would.
     
  36. ZolnierGames

    ZolnierGames

    Joined:
    Feb 19, 2018
    Posts:
    87
    Following up on my previous question - is there a way to rebuild the array of waypoints and spawn points at runtime if I enable and disable certain waypoint "groups" to address what I asked above?
     
  37. Stephen_O

    Stephen_O

    Joined:
    Jun 8, 2013
    Posts:
    1,505
    It sounds like you found the MoveAllCarsToPool method.

    The cars will spawn and use the routes available at startup. There's not currently a way to disable waypoints. I believe you're the first to request this, and also the first to attempt dynamic level loading. It's not currently a feature, but now that I know someone wants it I can add support for unloading/loading waypoint routes and spawn points at runtime.

    Not currently, a more detailed answer is above. I can add support for unloading routes/spawn points from the AITrafficController at runtime. I'll do this for the next update, which will be version 1.0.37, I'll post in this thread when it's submitted.

    Since you're in uncharted territory, when this update is available, please let me know how it works so I can make adjustments if necessary.
     
  38. ZolnierGames

    ZolnierGames

    Joined:
    Feb 19, 2018
    Posts:
    87
    Good deal! Thanks for the continued support on this very well-done asset! I can't wait for your 1.0.37 update!!
     
    Stephen_O likes this.
  39. Stephen_O

    Stephen_O

    Joined:
    Jun 8, 2013
    Posts:
    1,505
    Unfortunately it will only work with the car prefabs provided, humanoid models are not supported. The cars will be able to detect pedestrians, and stop for them if they have a collider using a layer that's assigned in the 'Detection Sensor Layer Mask'.

    Perhaps Simple Waypoint System from Rebound Games might be able to work for you? I haven't worked with any pedestrian assets enough to be able to recommend a good solution.
     
  40. ZolnierGames

    ZolnierGames

    Joined:
    Feb 19, 2018
    Posts:
    87
    Thinking about this even more - as you prepare your next update: If I group my waypoint routes and enable/disable their "active state" at runtime then just being able to call something like a "AITrafficController.Instance.RebuildRoutes()" would be great, in that it would recreate the array of waypoints and spawns, move all cars back to their pool (if necessary) and then (obviously) reset the DriveTarget location for the cars. Hopefully it's not too hard and it would add HUGE flexibility to this asset!
     
    Stephen_O likes this.
  41. Stephen_O

    Stephen_O

    Joined:
    Jun 8, 2013
    Posts:
    1,505
    No problem, I enjoy working on this asset, and am thrilled to learn what others would like to do. I can't add every request, but the ones that make sense, and are achievable will usually added. I haven't had many people use the API much, so it's good to hear you're pushing it a bit.
     
  42. Stephen_O

    Stephen_O

    Joined:
    Jun 8, 2013
    Posts:
    1,505
    I honestly won't know the exact solution until I sit down and tinker a bit, but yes, being able to achieve this would be the goal. The cars were recently updated to support runtime adding/removing from the AITrafficController, so technically speaking, supporting a dynamic-runtime system is half way there. I believe all that's needed now is to be able to do the same for spawn points and routes.

    Thanks for the extra info!
     
  43. amynox

    amynox

    Joined:
    Oct 23, 2016
    Posts:
    166
    Hi @Stephen_O ,

    thanks for your quick reply. Just watched all your tutorials (yes all of them) and the whole system seems well designed, congratulation.

    before buying, just want to know if cars can « try to avoid player/obstacle » that are blocking routes ? (I know that they can stop out of the box).

    as for pedestrians, yes I’ve been using SWS from rebound games for 4 yrs now, was thinking of using their asset to create a traffic system then I found yours :) so yeah I guess will still have to code another sys for pedestrians.

    ps: believe me, I will push your API as hard as I can (my first mission will be to make STS work with photon bolt :-D)

    thanks
     
    Last edited: Nov 18, 2020
    Stephen_O likes this.
  44. Stephen_O

    Stephen_O

    Joined:
    Jun 8, 2013
    Posts:
    1,505
    The change lane would be what they try to do if detecting obstacles, which is based on a cooldown timer, minimum speed requirement, side sensor detection, and if a connected point is available to switch to. So it's not something that would happen every time an obstacle is detected, only when all conditions are met.
     
  45. blaurain

    blaurain

    Joined:
    Jan 19, 2018
    Posts:
    10
    Hi, I imported everything and had the demo scenes running but once I started adding my own car models all the cars stopped moving at all. Now even when I re-import the whole project and demo scene, no cars are moving. Any thoughts? Thanks!
     
  46. Stephen_O

    Stephen_O

    Joined:
    Jun 8, 2013
    Posts:
    1,505
    Version 1.0.37 submitted.

    • Added WaypointRoutes array to AITrafficLight, allows assigning multiple routes to a single light. The single WaypointRoute field remains, to avoid breaking any projects while updating, it will be removed in a future version update.
    • Added support for adding/removing routes at runtime
    • Added support for adding/removing spawn points at runtime
    • Added isRegistered bool to AITrafficWaypointRoute
    • Added isRegistered bool to AITrafficSpawnPoint
    • Added RegisterRoute and RemoveRoute methods to AITrafficWaypointRoute
    • Added RegisterSpawnPoint and RemoveSpawnPoint methods to AITrafficSpawnPoint
    • Added GetRoutes method to AITrafficController, returns AITrafficWaypointRoute[]
    • Added GetSpawnPoints method to AITrafficController, AITrafficSpawnPoint[]
    • Added SpawnRegisteredTrafficEverywhere method to AITrafficController, allows respawning all cars in the same manner as scene startup
    • Added DisableAllCars method to AITrafficController, requires pooling
    • Added EnableAllCars method to AITrafficController
    • Added RemoveSpawnPoints method to AITrafficController
    • Added RemoveRoutes method to AITrafficController
    • Fixed a bug where moving cars to the pool would not reset the spawn point isTrigger to false if it was true

    In general, this update will allow you to add/remove routes and spawn points at runtime from the AITrafficController, providing support for runtime content generation/changes by expanding the API. Here's a runtime example script that can be added to an object in the scene, then call the functions from the component's context menu to test test.

    Code (CSharp):
    1. using UnityEngine;
    2. using TurnTheGameOn.SimpleTrafficSystem;
    3.  
    4. public class RuntimeExample : MonoBehaviour
    5. {
    6.     [ContextMenu("DisableAll")]
    7.     public void DisableAll()
    8.     {
    9.         AITrafficController.Instance.DisableAllCars();
    10.         AITrafficController.Instance.RemoveSpawnPoints();
    11.         AITrafficController.Instance.RemoveRoutes();
    12.     }
    13.  
    14.     [ContextMenu("EnableAll")]
    15.     public void EnableAll()
    16.     {
    17.         // Register spawn points example
    18.         AITrafficSpawnPoint[] spawnPoints = FindObjectsOfType<AITrafficSpawnPoint>();
    19.         for (int i = 0; i < spawnPoints.Length; i++)
    20.         {
    21.             spawnPoints[i].RegisterSpawnPoint();
    22.         }
    23.         // Register routes example
    24.         AITrafficWaypointRoute[] routes = FindObjectsOfType<AITrafficWaypointRoute>();
    25.         for (int i = 0; i < routes.Length; i++)
    26.         {
    27.             routes[i].RegisterRoute();
    28.         }
    29.         // Re-enables cars
    30.         AITrafficController.Instance.EnableAllCars();
    31.     }
    32. }
     
    Last edited: Nov 19, 2020
  47. Stephen_O

    Stephen_O

    Joined:
    Jun 8, 2013
    Posts:
    1,505
    Hello,

    I'm unable to produce any issues or errors with a download into 2019.4 LTS. Are you using an LTS version of Unity? Sometimes non LTS versions will have bugs (anything not labeled LTS is basically a beta).

    It could be you have made a mistake somewhere, I might recommend to completely delete the asset before re-importing. Are there any errors in the console?

    Another option could be to try a fresh project.

    A last resort could be a system restart, often I've experienced that Unity breaks if windows or my gpu needs an update.

    Also, when you added your own cars, have you followed the tutorial for adding new car prefabs?

    https://simpletrafficsystem.turnthegameon.com/tutorials/video-tutorials/new-car-prefabs
     
  48. amynox

    amynox

    Joined:
    Oct 23, 2016
    Posts:
    166
    There is a way to access car state to know when it’s « blocked » by player or other obstacle and CANT change lane ? For exemple to make the car use horn or flashing lights ?
     
  49. Maturajii

    Maturajii

    Joined:
    May 25, 2019
    Posts:
    2
    Hi, this asset is very easy to understand with lots of tutorials.
    But I'm in trouble.
    I am in trouble because the speed of the AI car is slow.
    What should I do?

    What i tried
    ・ The Mass of the AI car has been lowered.
    -Increased the Top Speed (150) and Acceleration Power (15000) of AI Traffic Car.
    -Increased the Speed Limit (150) of AI Traffic Waypoint.

    The Current Speed value stops at 50 miles.

    I would be grateful if you could help me.

    This sentence has been translated. I think it's hard to read. I'm sorry
     
  50. blaurain

    blaurain

    Joined:
    Jan 19, 2018
    Posts:
    10
    I am on an LTS release and I tried deleting the whole directory and re-importing (and restarting my machine) but no luck. no errors or warnings either. I upgraded my project manager's burst and collection plugins and I'm not even trying to use any custom cars at this time, just trying to run any of the demo scenes. All the cars spawn and have DriveTargets set, but they just sit still in their spawn locations. All the spawnpoints are set to a layer of "TransparentFX" but the rest of the level is marked as "Default", I'm not sure what else about my project could be messing with this. I tried importing this into an empty project and it works fine, so that means its something conflicting with the project settings or another asset?

    Edit: It looks like the layer the cars are set to in the clean project are labeled "SubCharacter" and in my other project layer 30 is "Item" and used by my character controller to (Not in this scene though). Would the layers be hard coded somewhere expecting that value or something?

    Edit 2: It looks like all cars in the version where they're not moving, are all targeting AITrafficWaypoint1 instead of other working version where they all have targets in front of them

    cars2.png
     

    Attached Files:

    • cars.png
      cars.png
      File size:
      556.4 KB
      Views:
      262
    Last edited: Nov 19, 2020