Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

[RELEASED] iTS - Intelligent Traffic System

Discussion in 'Assets and Asset Store' started by rhodnius, Dec 11, 2014.

  1. rhodnius

    rhodnius

    Joined:
    Apr 11, 2012
    Posts:
    1,334
    Hi Guys!

    We have just got live our new Traffic system (iTS - Intelligent Traffic System)

    Manual documentation

    Video showing how to setup the lanes and the basics of the system:



    Rigging the cars



    Links to the asset store:

    iTS Pro

    ITS core in dll


    Here is a web demo:

    Web Demo! (Police Car physics are from iRDS, which is a separate package)

    Super simple physics web demo (This demo does not use any wheel colliders on the traffic cars)

    Super simple physics with peds web demo (This demo does not use any wheel colliders on the traffic cars)
    Note: On the super simple physics demo, the cars have a single mesh, and the tires doesnt spin or rotate, but the super simple physics has the ability to also spin the tires and rotate them when steering is applied.

    Im the creator of iRDS - Intelligent Race Drive System.

    I would post more details soon.

    Rhod,
     
    Last edited: Aug 18, 2015
    Pulov likes this.
  2. sipon

    sipon

    Joined:
    Feb 8, 2009
    Posts:
    143
    Great work !
    Can we have a look at the doc ?
    I'd really like to see a video where you explain the setup !
     
  3. rhodnius

    rhodnius

    Joined:
    Apr 11, 2012
    Posts:
    1,334
    @sipon thanks for your comments!

    Yes sure you can, i will upload the docs soon and post it on the first post.

    Rhod,
     
  4. rhodnius

    rhodnius

    Joined:
    Apr 11, 2012
    Posts:
    1,334
    Just added the manual docs on the first post ;)

    EDIT: Would be uploading videos tutorial today!

    Rhod,
     
  5. rhodnius

    rhodnius

    Joined:
    Apr 11, 2012
    Posts:
    1,334
    Just added the first video tutorial :D

    Also the API docs is at our website

    Rhod,
     
  6. eridani

    eridani

    Joined:
    Aug 30, 2012
    Posts:
    655
    Three items:

    1. Can you make the pedestrians walk around your car if you park on the sidewalk?

    2. It looks weird that the pedestrians line up like cars (spaced far apart) when waiting for a light. Can you make them group together when waiting? (Maybe also some variation in position/interval when walking... right now they look like a robot army - see picture below)

    3. Is there a way to make the cars try harder to avoid hitting you? Right now they sometimes hit me when I'm partially in their way.

    Thank you!

    robots.png peds.png
     
    Last edited: Dec 12, 2014
  7. rhodnius

    rhodnius

    Joined:
    Apr 11, 2012
    Posts:
    1,334
    Hi @eridani
    R. Right now this is not directly possible, we could work on something for it for a future release.

    R. Actually you can change the space between them, i will update the demo.
    Also i added a feature to the system to make the peds not walk on the exact lane, so introducing variation to the position with respect to the lane and make it feel more random.

    R. This can also be changed on the settings, with the width multiplier of the player sensor of the traffic cars.

    Thanks for the comments,

    Rhod,
     
  8. dementcore

    dementcore

    Joined:
    Feb 6, 2013
    Posts:
    5
    Great work Rhod,

    I am thinking in creating a Street Racing Car game.

    I have a few questions about IRDS and iTs, i put in this thread because is about iTS.

    1- The IRDS AI cars will avoid the traffic cars and viceversa?

    2 - The traffic cars will avoid the player even if the player is not a car??
     
  9. rhodnius

    rhodnius

    Joined:
    Apr 11, 2012
    Posts:
    1,334
    @ningunosentertai Currently the IRDS AI Cars could avoid the traffic cars (there is an script from iRDS that needs to be added to the traffic cars in order for iRDS AI cars to detect the traffic cars) but this would be improved at some point to avoid using that script for the iRDS AI Cars to be able to detect the traffic cars.

    The traffic cars can avoid any other car of object that is in front of them and brake or change lane (this last one if there is another lane to switch to) the obstacle or car just need to have the tag "Player" on the game object that have the collider of that obstacle/car.

    The second question is answered on the last paragraph.

    Let me know if you have any other question.

    Rhod, :D
     
    Last edited: Jan 4, 2015
  10. Meceka

    Meceka

    Joined:
    Dec 23, 2013
    Posts:
    420
    Hello, I've just begun implementing ITS, but there is a problem.

    When using simple physics with wheels, front wheels switch z angle between 0 and 180. When I comment out front wheel steering code;
    commenting out this one is enough: frontWheels.localEulerAngles = tempAngles;
    Wheel doesn't steer, but rotates without problems, so it has something to do with it.
    I tried adding if conditions to make front wheel steering only work when car is steering, it kind of works but this time it still switches rotation and sometimes keeps that way. I also added tempangles.z=0f so that it won't ever be 180, but you can test it it still doesn't work well.

    Code (CSharp):
    1.  
    2. if(steering>5||steering<-5){
    3.                 Vector3 tempAngles = frontWheels[i].localEulerAngles;
    4.                 tempAngles.y = steering;
    5.                 tempAngles.z=0f;
    6.                 frontWheels[i].localEulerAngles = tempAngles;
    7.             }
    8.  
    Also there isn't clear description for making a super simple physics car. As I see it should have all the components and objects just like normal physics, but with supersimplephysics bool clicked. It disables other stuff automatically (wheel scripts and wheel colliders especially). Is this correct?

    When I want to switch between supersimple or normal physics, Do I just need to modify collider and that supersimple bool? Or is there anything else that I should modify?

    Edit: How can I make a truck with trailer for simple physics? I wish there was a pre-made one with demo scene, if you can't share a model, primitive models (cube) would work fine.
     
    Last edited: Dec 25, 2014
  11. rhodnius

    rhodnius

    Joined:
    Apr 11, 2012
    Posts:
    1,334
    Hi Meceka!

    Sorry for the late reply, was out for a little while, because of the Holidays, also i didn't receive an email from Unity notifying that there was a new reply on this thread, I'm going to make sure I'm subscribed to it, which i think is the default when you create a new thread:confused:

    About your questions, i would check out asap the rotation issue you have encounter, what i understand from your comment is that the wheel is not completing a full rotation, is that right?

    For using super simple physics, you need to rig the car as normal, and just enable the bool on the physics script that say Super simple physics ;)

    For switching from and to Simple physics, i't needs some code to be run, that actually is commented out on the physics scripts with a comment like this /*EXPERIMENTAL CODE, FOR ATTEMPTING TO AUTO SWITCH BETWEEN THE 2 TYPES OF PHYSICS, you can check those to see how i was testing it.

    About the truck with trailer, the way to go with it is pretty straight forward, you rig the truck apart, the for the trailer just add the collider and rigidbody to it, and create on the truck an empty child game object, move this new game object to where the pivot for the trailer joint would be, make the trailer be a child of that new game object (the trailer should get on the correct position from the truck (like it would be normally if attached to the truck).

    Then just add a configurable joint to the main object of the truck and set it up to have as connected body the trailer, and position the anchor at the place where the trailer is going to be attached to the truck (this is the pivot point) and setup the rotations limits, here is an example:

    upload_2014-12-29_11-46-30.png

    and a pic of the anchor placed between the truck and the trailer:
    upload_2014-12-29_11-50-12.png

    Let me know if you have any further questions.

    Rhod,
     

    Attached Files:

    Meceka and Cogent like this.
  12. rhodnius

    rhodnius

    Joined:
    Apr 11, 2012
    Posts:
    1,334
    @Meceka

    Here is the snippet with the modifications to correctly rotate the front tires, it seems that is something to do with how unity handles the assignment o the values when using localEulerAngles directly, so i modified it to simply just use that alone and not the Rotate function, here it is:

    Code (CSharp):
    1. Vector3 rotationAmount;
    2.     float rotation;
    3.     /// <summary>
    4.     /// Rotates the visual wheels.  This is part of the super simple car physics
    5.     /// </summary>
    6.     /// <param name="steering">Steering.</param>
    7.     void RotateVisualWheels(float steering)
    8.     {
    9.         float rotationValue = (mySpeed * 1.6f * Time.deltaTime) ;
    10.         rotation += rotationValue;
    11.         rotationAmount = Vector3.right * rotationValue * Mathf.Rad2Deg;
    12.         for (int i = 0; i < frontWheels.Length;i++)
    13.         {
    14.             frontWheels[i].localEulerAngles = new Vector3(rotation * Mathf.Rad2Deg, steering,0);// tempAngles;
    15.         }
    16.         for (int i = 0; i < rearWheels.Length;i++)
    17.         {
    18.             rearWheels[i].Rotate(rotationAmount);
    19.         }
    20.     }
    21.  
    Thanks for the feedback, would be updating the package soon on the asset store with a few new features, like the ability to swap the lanes direction while in edit mode, (would be available only if there is no connector attached to the lane, or if there is connectors, the connectors would be removed, since swapping the lane direction would also alter the current linked connectors to it and mess the direction of them too).

    Thanks again!

    Rhod,
     
  13. Meceka

    Meceka

    Joined:
    Dec 23, 2013
    Posts:
    420
    Thanks Rhod, There is another bug;

    https://www.dropbox.com/s/eoqcidcpof2dnqf/traffic.png?dl=0

    This happens a lot even if the correct connection is closer such as in this picture.

    Another problem; There is no way to disable audio for traffic cars. I had to modify the code and add a bool if(AudioEnabled){(some audio code in ITS)} so that it won't give NullReferenceExpections, please add a bool to enable/disable audio for each car this way.
     
    Last edited: Dec 29, 2014
  14. Meceka

    Meceka

    Joined:
    Dec 23, 2013
    Posts:
    420
    Here is another and one that really shows how often and awkward it happens;

    https://www.dropbox.com/s/ap8qtckjm98kroq/traffic2.png?dl=0

    I am drawing waypoints from right to left, Blue line is what it the connection that could happen, but it does that weird yellow line with connecting to wrong points.

    Right now there is another problem with box colliders physics (they get stuck in most places if collider isn't one perfectly clean mesh), I will illustrate that later.

    Do you think there is a way to spawn carss mostly in front of the players camera angle (In the way how frustum collider works), right now it spawns half of the cars behind player when player is moving. If we could set it to spawn 80% in front and 20% in behind it could act more efficient, we could reduce the amount of cars but still have same dense traffic effect. Right now I am testing with 10 cars with simple physics, audio disabled, physics time step: 0.04 but it reduces fps from around 35 to around 15-20, I hope to find a way to improve performance from some other areas. Do you have any recommendations to improve performance further?

    All in all, ITS is great, thanks.
     
    Last edited: Dec 29, 2014
  15. rhodnius

    rhodnius

    Joined:
    Apr 11, 2012
    Posts:
    1,334
    Hi Meceka,

    It seems like the pics are not show on your post , could you please send me them by email or try to add them again in the posts? :)

    EDIT: seems like those pics are in a private folder of dropbox maybe?
     
  16. Meceka

    Meceka

    Joined:
    Dec 23, 2013
    Posts:
    420
    Just fixed the links.
     
  17. rhodnius

    rhodnius

    Joined:
    Apr 11, 2012
    Posts:
    1,334
    Thanks!

    I totally understand what you mean now, I'll check that asap!

    About the Boxcolliders physics, this is something i explained early, and is more an issue of the PhysX engine, the best way to avoid issues while dragging an object is having a smooth collider for the road for now, i also tried using cylinders for the cars (as if those were the tires) but the result is the same if the surface is not smooth. ( i would think of something else to work around this).

    There is a way to spawn cars in front of the spawner forward direction, this would require some other additional mods, i could work on them for a future update release, this is a great idea! :D

    About the performance, on which device you are doing the tests?

    Thanks for the feedback!

    Rhod,
     
    Last edited: Mar 4, 2015
  18. rhodnius

    rhodnius

    Joined:
    Apr 11, 2012
    Posts:
    1,334
    Hi guys!

    What i did to avoid the issue @Meceka was commenting before, is the ability to press and Hold "Shift" while adding/Editing the lane points to add them always after the last point of the lane, this way is more like an add while pressing Shift, and like insert while not pressing the Shift key ;)

    Rhod
     
  19. rhodnius

    rhodnius

    Joined:
    Apr 11, 2012
    Posts:
    1,334
    I have already submitted the update yesterday! It is still pending approval from UAS team.

    Rhod,
     
  20. dementcore

    dementcore

    Joined:
    Feb 6, 2013
    Posts:
    5
    Hi @rhodnius !
    Thanks for your quick reply!!

    NingunosEntertainment
     
  21. Meceka

    Meceka

    Joined:
    Dec 23, 2013
    Posts:
    420
    Hello;
    There is a problem with player detection, I can see player collider hitting the player car, but usually, they slow down a bit, and when player car gets in in the colliders volume, it totally ignores the player. This usually happens when traffic are fast, or if they crashed to player once.
     
  22. rhodnius

    rhodnius

    Joined:
    Apr 11, 2012
    Posts:
    1,334
    Hi @Meceka,

    Please make sure the GameObject that have the collider of the player has the tag "Player" on it, please confirm this to be sure this is not the issue :D

    Rhod,
     
  23. Meceka

    Meceka

    Joined:
    Dec 23, 2013
    Posts:
    420
    Yes it has player tag, (we should be able to modify which tag it should check check player for).
     
  24. rhodnius

    rhodnius

    Joined:
    Apr 11, 2012
    Posts:
    1,334
    Ok thanks for the feedback, i would check it asap, and also add what you are suggesting, it is definitely something that needs to be there.

    Thanks again, ill get back shortly.

    Rhod,
     
  25. rhodnius

    rhodnius

    Joined:
    Apr 11, 2012
    Posts:
    1,334
    Just checked about the Player Tag, and it was there, but as private member, i forgot to change it to public, it is now set to be a public member, would be uploading it soon, after checking the issue @Meceka reported about player detection.

    Rhod,
     
  26. rhodnius

    rhodnius

    Joined:
    Apr 11, 2012
    Posts:
    1,334
    @Meceka, just did a test, and the cars are detecting the player, i think what you may experience is that the traffic cars brake torque is too low (try a value of 250), and the traffic cars are then not been able to brake when they detect the players, also there is a min Player sensor length setting on the TSTrafficAI class, make sure it has a value of 5 more or less, to be able to detect the player when they are at full stop.

    Let me know if this solves the issue :D

    Rhod,
     
  27. rhodnius

    rhodnius

    Joined:
    Apr 11, 2012
    Posts:
    1,334
    Hi guys!

    The new version is on the asset store now, V1.0.1

    Cheers,

    Rhod,
     
  28. lewisq94

    lewisq94

    Joined:
    Oct 10, 2013
    Posts:
    1
    Dose this support unity 5?
    Thanks, Lewis
     
  29. rhodnius

    rhodnius

    Joined:
    Apr 11, 2012
    Posts:
    1,334
    Hi lewisq94!

    Yes and no, the system by itself does support unity5, the car physics, which is based on wheelcolliders needs a modification in order to be used with the new physx on Unity5, since the wheelcollider behavior has changed.
    The other physics, which is a simpler physics without wheelcolliders, works just fine with Unity5.

    I would be working on it and update soon a new vehicle physics support for Unity5.

    Rhod,
     
  30. rhodnius

    rhodnius

    Joined:
    Apr 11, 2012
    Posts:
    1,334
    I just have done some test, and what i see that needs changing is the value of the damper of the traffic cars, so just putting a value of 5000 made the cars stable (since with the other values they start to bounce), and the cars start to drive normally, with a lower speed than in Unity 4.x.

    Those are the test i have done so far, no errors shown on the console too.

    I'll keep you updated.

    Rhod,
     
  31. rhodnius

    rhodnius

    Joined:
    Apr 11, 2012
    Posts:
    1,334
    Ok, i have to say that iTS is Unity 5 Compatible, and this is what you need to change in order to get it work properly (No script modification is needed):

    1. Adjust the settings of the wheelcollider spring and damper, to values that make it work properly, from the values that come by default in the demo traffic cars, raising the damper to 5000 would do the job and the Target position to 0.5.
    2. Adjust the motor torque value of the iTS Simple Physics script on the inspector to a higher value, i.e. 400
    3. Hit play and enjoy!


    Rhod,
     
    Last edited: Mar 4, 2015
  32. pinchmass

    pinchmass

    Joined:
    Jul 2, 2012
    Posts:
    156
    Hi I'v adjusted the setting on car as described above, and all seems fine, but I just notice, my cars some to get stuck / sling going uphill
     
  33. rhodnius

    rhodnius

    Joined:
    Apr 11, 2012
    Posts:
    1,334
    You may need to increase the engine torque for the cars to go uphills. If this doesnt help ket me know.

    Rhod,
     
  34. carking1996

    carking1996

    Joined:
    Jun 15, 2010
    Posts:
    2,608
    I bought your system and it's pretty decent.. but it needs some work in areas:

    - I made the vehicles faster(they were extremely slow by default). I made their torque 1000 and max speed 50. Then braking is at 2600. Turn speed is default as is everything else. But they don't turn well and it'd be nice for them to be able to be a little more predictable(more perfect?) with this.

    - They shake/wobble when stopped at a light/behind other traffic.

    - With the super simple physics, the bodies of the cars turn on/off. It seems to be the renderer from looking at it, but looking over your code, nothing changes within the renderer of the vehicle body(nor is it assigned to anything), but it's forced off when it's off.

    Note: I am using Unity5.
     
    Last edited: Mar 20, 2015
  35. rhodnius

    rhodnius

    Joined:
    Apr 11, 2012
    Posts:
    1,334
    Hi carking1996!

    Thanks for your purchase!

    Please kindly send me your invoice number to register your product at josegarrido@dagagames.com

    about your questions, here are the answers:
    In this case, a little more detail would be good to know how to help you out, i.e. arw they skidding when they do the turn? Or maybe is also because of the next point, that they shake/wobble? Since the default settings of the cars are for the unity 4, you need to tweak the suspension setting to a good value to avoid this shake ans wobble, since the traffic cars uses pure wheelcolliders physics.

    See the reponse from the previous answer.

    There is an option to make a renderer turn on and off, which is for the tail lights, make sure that on the brake lights renderer array is not assigned the car body.

    Thanks for the feedback, and let me know if you need anything else.

    Rhod,
     
  36. carking1996

    carking1996

    Joined:
    Jun 15, 2010
    Posts:
    2,608
    Hello, they aren't really skidding when they turn.. it's more of then just moving too fast. Also, when editing connectors with the lanes, this error slows the editor down a lot, it's a bit frustrating.

     
  37. rhodnius

    rhodnius

    Joined:
    Apr 11, 2012
    Posts:
    1,334
    Hi carking1996!

    In this case you need to go to the iTSMainManager and on the settings tab, look for the corner speed multiplier for lanes and connectors and make that value smaller, like 0.7 then press the Process Junctions button, and the cars should slow down more on the corners.

    About the error, im going to take a look at it right away.

    Rhod,
     
  38. carking1996

    carking1996

    Joined:
    Jun 15, 2010
    Posts:
    2,608
    One more thing users might find useful. Default Parameters for roads(I haven't seen any yet). For example I am having to set each street width and speed and density one by one. ;)

    Also, docs for the traffic spawner and traffic AI scripts would be wonderful to have. I couldn't find it in the docs included.
     
    Last edited: Mar 21, 2015
  39. rhodnius

    rhodnius

    Joined:
    Apr 11, 2012
    Posts:
    1,334
    Yep I'll check those are included.

    Thanks!

    Rhod,
     
  40. carking1996

    carking1996

    Joined:
    Jun 15, 2010
    Posts:
    2,608
    Hello again. I've noticed two streets that cars like to just stop at after a shot amount of time. There's a small gap in the mesh there but is that a problem? I tried adding more points to the lane, but that didn't change anything. Screenshots attached.

     
  41. rhodnius

    rhodnius

    Joined:
    Apr 11, 2012
    Posts:
    1,334
    Hi carking1996!

    Well, if the mechcollider doesn't have that gap it should be ok, what could be happening is that the actual points that are been placed on top of the meshcollider, you could try something really simple out, add a quad there without the mesh renderer just to fill that gap, edit the lane points from the lanes that are passing the gap to make sure all the points get in top of the surface and then press Process Junctions and give it a try.

    Let me know if this solves the cars from stopping at that point.

    Edit: Did the dlls i sent you yesterday, solved the exceptions you was getting while editing the lanes and connectors?

    Rhod,
     
  42. carking1996

    carking1996

    Joined:
    Jun 15, 2010
    Posts:
    2,608
    I fixed it, and yes the DLLs helped a bit. Is there any more ways to optimize this? I'm using simple physics, but require a lot of vehicles on the screen at once.
     
  43. rhodnius

    rhodnius

    Joined:
    Apr 11, 2012
    Posts:
    1,334
    Hi carking1996,

    Would be great if you could share what was causing it, and how you solved it, so i could make a proper fix if needed :)

    About the optimization, for which platform and how many cars you want to have at the same time?
    The system uses a respawning system to make the feeling that there are more cars near the player, so having actually less cars on the scene you still have the feeling that there are way more cars.

    I would be revising the code to check for any other performance increase that could be achieved.

    Cheers,

    Jose,
     
  44. carking1996

    carking1996

    Joined:
    Jun 15, 2010
    Posts:
    2,608
    I need around 125 vehicles around the player at a time, around the area. I fixed it by doing as you said, the mesh collision was odd.
     
  45. rhodnius

    rhodnius

    Joined:
    Apr 11, 2012
    Posts:
    1,334
    Ok i see, this is for PC/Mac ? You should have way better performance when you build the game and run the build for sure.

    About the fix, also i was asking about the errors you had on the console, were those gone with the new dlls?

    Rhod,
     
    Last edited: Mar 22, 2015
  46. carking1996

    carking1996

    Joined:
    Jun 15, 2010
    Posts:
    2,608
    I can confirm the DLL worked for that, too, at least better pretty much almost no errors from what I've seen. And I was running it in pc just now and it works pretty decently well. Great job with the system and I hope to see some more optimizations in the future.
     
  47. rhodnius

    rhodnius

    Joined:
    Apr 11, 2012
    Posts:
    1,334
    Thats great!

    If you see any other error please let me know to squash those asap.

    Cheers!

    Rhod,
     
  48. carking1996

    carking1996

    Joined:
    Jun 15, 2010
    Posts:
    2,608
    From observation, I believe the most laggy device is the spawner. Would it be possible to do a pool instead of instantiating? That way you can set a certain amount of vehicles in the world, then move them around instead of instantiating them(which is heavy).
     
  49. rhodnius

    rhodnius

    Joined:
    Apr 11, 2012
    Posts:
    1,334
    Hi carking1996!

    It already uses a pool for that purpose precisely. ;)

    Rhod,
     
  50. carking1996

    carking1996

    Joined:
    Jun 15, 2010
    Posts:
    2,608
    Ah, alright. Is there a way to do something like have quadrants the player can enter in(specify the player by a tag) and have them go there instead of having a check every x seconds with the spawner? That could possibly be quicker. The system itself a pretty fast I see, it's just the spawning that's slowing it down(even in builds) the most.