Search Unity

  1. Unity 2020.2 has been released.
    Dismiss Notice
  2. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Open source AI Traffic System that really works out of the box!

Discussion in 'Works In Progress' started by Marcos-Elias, Feb 27, 2016.

  1. Marcos-Elias

    Marcos-Elias

    Joined:
    Nov 1, 2014
    Posts:
    121
    Hello guys! First of all, I hope you can understand my English even with mistakes.

    I was looking for a free script or tutorial on making an AI traffic system on Unity. There are some tips and tricks out there, but it is very hard to get things done. Waypoints placed manually... Oh, no! This is so time consuming... All the best methods for placing AI cars into your projects were paid... As an indie developer, I don't have enough money to buy that expensive systems. Some cheap code I have tried was difficult to work with... So... 2 years later... I'm making my own AI system for Unity now!

    I think I'll be making something different: this will be OPEN SOURCE and FREE FOR EVERYONE. But I need some help...

    Check some progress for the last 2 weeks (please note that those AI cars WON'T be available, they were bought on Asset Store for my own game; you will have to use your own cars):



    My system can handle LOTS of cars on PC!



    I'm looking for new freelance jobs here where I live, I need money and want funding for my game, as everyone else... So... How about making some money with a system that I love? I believe that I can sell my script (once finished) for $100 (it's easy to use, lightweight and works almost automatically, and will come with some road pieces). But I want to help other indie devs too, and I love open source software... I think I'll be making a crowdfunding campaign for this project.

    If you like and use it, would you pay me something? You put the price. I really need money nowadays to work 24/7 on this project, but I don't want to sell this code. I believe that making it available as open source software is the better thing to do, since there is NO free alternative yet (if there is some... I did not find it!). By being open source, more people will improve it and everyone else will enjoy the finished project!

    I'm making this mainly for my own projects, which includes driving in busy cities - a bus simulator, truck simulator, cars... etc. My system is good for any driving game and open world like GTA style.

    My AI traffic system will be very good at its key features:

    * Fast and lightweight code. I don't have plans to move the cars using physics for performance reasons. And even better, with kinematic movement, all the objects will follow all the paths, with no strange behavior caused by collisons. By the way, once released, you will be able to use physics if you want.
    * My system can handle LOTS OF CARs. Bring your cities to life!!! It's so boring when you have a road with no car... I want to make some real roads where the player will be around with 500+ detailed AI cars.
    * Unlike other other AI traffic systems, my AI scripts will be very easy to use! Just place the roads and intersections, set your own cars and the AIs will appear automatically! Of course you can disable auto spawn, spawn custom AIs at desired places (like buses or trains), change the max amount of cars on the scene... And so on... Using my road prefabs and vertex snapping you can put your work on making your levels. It will be easy to make your own roads and crossings/junctions too! You may use prefabs, or put the paths directly on terrain or any other road system!!! Since I don't use physics to move the AI, I hope this works for trains, airplanes, ships, planets...
    * There will be traffic lights! (almost done)
    * There will be pedestrians and sidewalks! (not coded yet, but it will be the same for cars, bicycles, etc)
    * There will be right and left turns! (not coded yet)
    * I hope there will be indicator lights on cars (not coded yet).

    I plan to release a preview in some weeks or months, depending of what progress I achieve. I really love this system. It would be nice if can work on it 24/7 while I don't earn money with my games.

    I want money to fund my own bus simulator, it's an old dream. I make mods for OMSI, a german bus simulator, but it is closed and has many open bugs... So I started making my own project. I need money also to buy new hardware and some assets on the Asset Store for my games - like cars, buildings, low poly people etc.

    It's about one helping each other. I help you with my AI car system. You help me with some money... What do you think?

    If you want you may wait a beta, so you can try my code and see the results. My AI script is very promising. I'm in love with this!!!

    If you can pay $30, that will be ok; if you can pay $100, ok! That's good! If you really like the project and make money with your game where my code takes special place, please make a donation to help me with my other projects. It's not about selling here, it's about helping each other.

    As I said, I will launch this project even for people who can't pay, to help indie devs. Once they were making some money with their games, they can retribute me. I hope.

    Some details are here at my blog, in Portuguese:
    http://www.explorando.com.br/mep-ai-traffic-unity/
    I'll be making some videos in English to show how to use my system. It is a very basic thing, but as I saw no one yet had put it together into a FREE, FULLY AUTOMATED AI CAR/BUS/TRAIN SYSTEM.

    What do you think? Any feedback is welcome!
     
    Last edited: Feb 27, 2016
  2. HeadClot88

    HeadClot88

    Joined:
    Jul 3, 2012
    Posts:
    714
    This is pretty cool!
     
  3. ANTARES_XXI

    ANTARES_XXI

    Joined:
    Dec 23, 2014
    Posts:
    141
    Very nice! Good job :)
     
  4. carking1996

    carking1996

    Joined:
    Jun 15, 2010
    Posts:
    2,564
    Looks great! Spawning should be more random so vehicles aren't lined up, and some vehicles like smaller cars, should move a tad faster than buses and trucks. Awaiting more updates, although I already use the iTS traffic system myself.
     
  5. Marcos-Elias

    Marcos-Elias

    Joined:
    Nov 1, 2014
    Posts:
    121
    Thanks for your feedback!

    Antares, this is planned :D Spawn positions can be edited per object or prefab, and I plan to randomize them at runtime (some decimal units backwards or forward). About velocity, that's true, small cars will be faster than heavy vehicles. And it will be also possible setting a desired velocity per street lane, with a special object (a trigger/box collider).
     
    looki666 likes this.
  6. looki666

    looki666

    Joined:
    Sep 5, 2013
    Posts:
    79
    Any Updates ?:)
     
  7. Marcos-Elias

    Marcos-Elias

    Joined:
    Nov 1, 2014
    Posts:
    121
    I'm working on other things for now, like modeling new roads and fixing my other scripts... The project is not dead, but will need more time to get online :D
     
    looki666 likes this.
  8. wahyuway

    wahyuway

    Joined:
    Oct 7, 2013
    Posts:
    81
  9. Marcos-Elias

    Marcos-Elias

    Joined:
    Nov 1, 2014
    Posts:
    121
    Hello, I'm still working on this project, improving it in my free time. I've added some randomization on distance checking so the cars will behave differently, more natural. But it is far away from release, still needs many hours of work.
     
    John-G likes this.
  10. Salzian

    Salzian

    Joined:
    Feb 17, 2017
    Posts:
    7
    Hi Marcos-Elias.

    I suffer from the same problem you have. Indie-Devs have no money to buy the good, but expensive assets like "Ti Traffic AI" (225$). I currently work on an own system which is far less advanced than yours. Your system looks VERY promising. I would also consider paying between 10$ and 20$ for this (I'm a broke student with not much money), since I've seen it in action. Keep up the good work. I'll follow your development.
     
  11. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,440
    @Marcos-Elias do you have any public repo for this project where we can follow?
     
  12. Salzian

    Salzian

    Joined:
    Feb 17, 2017
    Posts:
    7
    I would definetly consider contributing on it.
     
    Reanimate_L likes this.
  13. Marcos-Elias

    Marcos-Elias

    Joined:
    Nov 1, 2014
    Posts:
    121
    Hello, it is nice to see that you like the system!

    Currently it is not published yet, I must separate some considerable time to make a basic documentation on how to use it before publishing. I plan to do it soon (in some weeks).

    The setup will take some time but once the prefabs are made we just need to put them into scene and it starts working.

    I must also remove the people and cars that I'm using, since they were paid assets that I bought. I'll replace with some free models before launching.

    Currently I'm adding collisions, when the player collide with the AI car, the AI will get its rigidbody and wheel colliders activated. There are some recent videos on my channel on YouTube.

    I think that if I launch this in its current stage I can get some donations to buy 3D models for my game projects, not too much but just a few of each one already helps a lot :D

    Since the system is far from complete, I cannot sell it now. And I really want making it open source.

    Just wait some more weeks and I'll update this thread with the project for download :D
     
  14. Salzian

    Salzian

    Joined:
    Feb 17, 2017
    Posts:
    7
    Can't wait to see your results. I currently achieved a dynamic braking system. As faster the cars go as earlier the car starts to break. I've uploaded a demo to my website: http://djsandmanntv.de/unity/traffic-ai/
     
  15. longroadhwy

    longroadhwy

    Joined:
    May 4, 2014
    Posts:
    1,489
    What paid assets (people/cars) are you currently using?

    I like the concept of this project.
     
    Last edited: Feb 19, 2017
  16. MD_Reptile

    MD_Reptile

    Joined:
    Jan 19, 2012
    Posts:
    2,628
    This seems cool, hope to see it when its done!
     
  17. mkg2w

    mkg2w

    Joined:
    Aug 19, 2013
    Posts:
    39
    How is this going ? Would love to understand how this works on mobile.
     
  18. Marcos-Elias

    Marcos-Elias

    Joined:
    Nov 1, 2014
    Posts:
    121
    Hello guys, sorry for not posting any update for a long time!

    Currently I don't have enough time to make and release this for free, so I'm developing it inside my project for now, at a slower speed (I must work on many things, not only on the game itself). It still depends on some parts of my other exclusive scripts for now... Separating the traffic system and writing documentation/tutorials would require a huge amount of hours, that I cannot afford for now.

    I still plan launching this some day, but unfortunately I cannot say "when" (because I don't know exactly when I'll have such free time).

    You may watch the current progress here:


    With traffic lights and more cars:


    Or download and try it yourself, on Android:
    https://play.google.com/store/apps/details?id=com.viamep.protonbussimulator

    Windows/Linux/Mac:
    http://blog.brtsimulator.com/2017/06/download-pc.html

    This project still relies on MoveTorwards instead of using Wheel Colliders, it is much simpler and it is not good at curves yet. There are a lot of work to be done. The main concepts are working well.

    I must make a "physics version" to use wheel colliders, I already tried that but due to the lack of time, it will be impossible for now.
     
    Last edited: Aug 22, 2017
    Antypodish likes this.
  19. GGforJ

    GGforJ

    Joined:
    Sep 26, 2017
    Posts:
    2
    pretty cool! I am doing something about this now and I want to learn something about AI from your project !
     
  20. Salzian

    Salzian

    Joined:
    Feb 17, 2017
    Posts:
    7
    Any new updates on the project yet?
     
  21. JeyP4

    JeyP4

    Joined:
    Mar 6, 2018
    Posts:
    16
    Hey
    Great Project. :)

    When are you going to publish it??
     
  22. Marcos-Elias

    Marcos-Elias

    Joined:
    Nov 1, 2014
    Posts:
    121
    Hey guys, sorry for not posting an update for a long time!

    I was too busy with work, I still have no time to separate it from my main project, create sample vehicles and provide documentation.

    I don't have an estimate date or answer about "when", but I still have plan to release this :)

    I got stuck with some physics too, once released more people could contribute to make it better.
     
  23. carking1996

    carking1996

    Joined:
    Jun 15, 2010
    Posts:
    2,564
    I would honestly say just release it, docs or not, people will figure it out and make their own changes. Just put up the project and see where people take it.
     
    Pug-Man and tredpro like this.
  24. MD_Reptile

    MD_Reptile

    Joined:
    Jan 19, 2012
    Posts:
    2,628
    Plus some of us might help fix some things!
     
    HeadClot88 likes this.
  25. Pug-Man

    Pug-Man

    Joined:
    Apr 18, 2018
    Posts:
    2
    Would love to see you release this
     
  26. Marcos-Elias

    Marcos-Elias

    Joined:
    Nov 1, 2014
    Posts:
    121
    I must take at least some days to separate it from my project, there are files that are mixed (settings, prefabs, etc), some variables are in Portuguese and if I change them it will break my current prefabs, and so on... It's not that easy.

    I have to create a few sample prefabs with free objects (I cannot share all assets that I use, most models were bought). Sorry but I still have not an entire week to get this done properly, as I'm working with lots of things.

    By the way it will be a free asset, so more people could work together and improve it. I wish a spline based asset but I don't know how to do that, creating smooth paths between curves without losing its easy-to-use settings. I also tried making a physics-based version but it is not stable. I hope that in the future it will be able to move cars with wheel colliders - at least the ones that are closer to the camera, to save performance on cars that are far away.

    I'll do my best to release this in some weeks or in a few months, and a basic guide. Really sorry about my "delay".

    It could be a paid asset but I'll share it for free, something like "pay what you think it is worth it if you really like it". There is no other similar easy to use asset for vehicle traffic, as far as I know.
     
    JeyP4 and MD_Reptile like this.
  27. aymanokha

    aymanokha

    Joined:
    Jan 14, 2018
    Posts:
    1
    Hy Any updates
     
  28. Testmobile

    Testmobile

    Joined:
    Jul 3, 2012
    Posts:
    99
    You must really like public transport!
    Nice simulator, it has all the bells and whisles, the passengers getting in/out was really a nice touch aswell!
     
  29. ecm_dave

    ecm_dave

    Joined:
    Jul 26, 2013
    Posts:
    4
    Man this is just what I need right now, good luck on your project, hopefully we will see the release of this asset soon, as you say there is nothing like it available, even still to this day.
     
  30. GamePyro

    GamePyro

    Joined:
    Jul 28, 2018
    Posts:
    157
    Any news ?
     
  31. MD_Reptile

    MD_Reptile

    Joined:
    Jan 19, 2012
    Posts:
    2,628
    @Marcos-Elias Bump - I second on that "any news" post above.

    Have you finished the game you were planning on using this system in? Any plans yet to get a open source system on github or similar site, so we may contribute to furthering your system?

    Perhaps if it would motivate you to release it, consider doing an asset store paid asset instead of free, even if its relatively cheap, so that you have more motivation to progress the system as a standalone package... and keep in mind that there is a bit of a void on the asset store for this sort of thing, which you could capitalize on...
     
  32. ecm_dave

    ecm_dave

    Joined:
    Jul 26, 2013
    Posts:
    4
    Any update? Would love to take a look at this system and see if I can get the physics based vehicles for up close lods working for ya. Can't wait to see what you've got going on here!
     
  33. GamePyro

    GamePyro

    Joined:
    Jul 28, 2018
    Posts:
    157
  34. MD_Reptile

    MD_Reptile

    Joined:
    Jan 19, 2012
    Posts:
    2,628
  35. RACHITSINGH433

    RACHITSINGH433

    Joined:
    Oct 17, 2018
    Posts:
    3
    Any updates?
     
  36. sonicviz

    sonicviz

    Joined:
    May 19, 2009
    Posts:
    1,042
    Helllllllllllllllllllloooooooooooooooooooooooooooooooooooooooooooooooooo!

    Any updates???
     
  37. Artur93

    Artur93

    Joined:
    Jul 21, 2019
    Posts:
    1
    Any code?
     
  38. Marcos-Elias

    Marcos-Elias

    Joined:
    Nov 1, 2014
    Posts:
    121
    Unfortunately I've got so many other priorities in life that made it impossible to release it the way I originally wish. Sorry but I *still* could not get the 2 or 3 completely free weeks needed to separate it from my project and make a great tutorial. It got improved a lot since the beginning but there are still many things to work on. Also updates to Unity 2019.x broke some parts due to changes in PhysX.

    By the way this section of the forum is work in progress, I still plan to release it somehow.

    For such a mid-complexity project I think that it is better not releasing it than releasing with poor or no support at all, as many devs on the Asset Store do, to avoid the creation of paid clones... Until it is more like a finished product.

    There are many assets that are WIP for many months, more than expected, but in the ending everything makes it worth it.

    I'm really sorry if this post made you frustrated.
     
  39. Salzian

    Salzian

    Joined:
    Feb 17, 2017
    Posts:
    7
    If you would release it as WIP on GitHub you could further develop it using the help of the community. I was looking for a good basis of an AI system for quite some time now and I would be possibly interested in working on it. Your lib may not be production ready, but in your videos we could already see a good basis that can be build upon.

    You could even handle it as a separate package for easy import since Unity now supports external packages in it's Package Manager from other sources like GitHub. Let me know if you need some help setting this up and/or decoupling the Library from your project for a proper release. Contact details in profile.

    This is supposed to be an open source project... how would that be a problem? Also, with the right license you could request Unity to take down the clone as long as it is 1:1. Deriviate works obviously are allowed by open source principles.
     
  40. danielmhina34

    danielmhina34

    Joined:
    Sep 11, 2020
    Posts:
    3
    Dude my english is not good but i hope you will understand me. i am an indie developer and
    i've been following you on Youtube and i really like your projects. for a very long time i wanted to create a BRT simulator but my skills are very low i only know how to set them wheelcolliders and move a car. If you can help me cause im broke, where can i find free script or simple projects for traffic system. Thank you and Nice job dude.
     
  41. MD_Reptile

    MD_Reptile

    Joined:
    Jan 19, 2012
    Posts:
    2,628
    These are few and far between. Your gonna be hacking something together using tons of examples and learning as you go for the most part, because there is only a couple examples of this out there and they often aren't unity specific.
     
    danielmhina34 likes this.
unityunity