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

Assets NWH Vehicle Physics

Discussion in 'Works In Progress - Archive' started by NWHCoding, Nov 30, 2017.

?

Which networking solution do you want to see implemented?

Poll closed Jan 20, 2019.
  1. UNet - Unity Networking, getting deprecated sometime in the future

    1 vote(s)
    4.8%
  2. Mirror - Community replacement for UNet (https://github.com/vis2k/Mirror)

    6 vote(s)
    28.6%
  3. Photon

    12 vote(s)
    57.1%
  4. None - I will be implementing my own solution

    2 vote(s)
    9.5%
  1. DeathRace26

    DeathRace26

    Joined:
    May 26, 2019
    Posts:
    75
    Alright, i got working suspension in a way needed, it took quite some time figuring out. It would be nice to have just one float for each wheel representing collision offset depending on side of the wheel. Could this be a feature?
     
  2. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,630
    Just tested and working as intended. If you need to move your wheels out you can just move your WheelController objects outwards and that will move the wheel with itself. If you could illustrate the problem it would be great.

    To make sure we are on the same terminology, rim offset is this:


    Center of rotation will stay the same when increasing the offset.
    If you need to move center of rotation, move the object containing WheelController script as it represents the suspension anchor.
     
  3. sonicviz

    sonicviz

    Joined:
    May 19, 2009
    Posts:
    1,046
    Nice work! You should release it as an asset.
     
    VermilionGames likes this.
  4. TiToMoskito

    TiToMoskito

    Joined:
    Jan 28, 2014
    Posts:
    64
    How do i rotate the right wheels?

    Correct Left Wheels


    Incorrect Right Wheels
     
  5. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,630
  6. geralex

    geralex

    Joined:
    Apr 17, 2014
    Posts:
    7
    I tried to separately the search for objects by tag, it does not help.

    Code (CSharp):
    1. public TrailerHandler trailer = new TrailerHandler();
    2.  
    3. trailer.trailerGOs = GameObject.FindGameObjectsWithTag("Semi Trailer");
     
  7. Davood_Kharmanzar

    Davood_Kharmanzar

    Joined:
    Sep 20, 2017
    Posts:
    411
    @NWHCoding

    hi dear,

    can you provide this asset with Unity Jobs?
    and with MiRROR networking compatible too?

    thanks.
     
  8. LunyMoonraker

    LunyMoonraker

    Joined:
    Mar 11, 2015
    Posts:
    12
    Really great job! Loved it for almost a year now, but I have just one small problem when I use a different player controller it works in the editor for camera changer but when I build and run it doesn't at all. Really great work though, keep it up but I hope you can help me.
    Thank you.
     
  9. mthawley

    mthawley

    Joined:
    Sep 7, 2018
    Posts:
    100
    Hi. I currently allow the player to pause the game to enter a menu system using Timescale = 0. When resuming the game (Timescale = 1) the car often is thrown into the air. Any ideas what could be causing this? Cheers.
     
  10. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,630
    You say often? Does that means that it is not always thrown in the air?
    Any specific circumstances in which this happens or is it just random?
    Tried in V2 and it does not happen, will try to replicate in V1 in a few moments.
    One thing that might happen is that any code that is calculating velocity might get very large Time.deltaTime or some other time-bound variable.

    Edit: Tried in V1 and could not replicate.
     
    Last edited: Feb 4, 2020
  11. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,630
    Hello, check your email inbox.
     
  12. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,630
    I already made a lengthy response about jobs and how they are used for raycasting but for everything else in the asset not really applicable. My other asset, Dynamic Water Physics 2, is using Jobs and something similar to Unity's ECS to simulate the objects floating in water but that case lends to jobs much better since there are hundreds of triangles to simulate. On the other hand moving NWH Vehicle Physics to jobs with <30 vehicles per scene would not result in much improvement (if any) with a lot of added complexity. There is a lot of data to be copied into the native arrays and back
    which would also generate a lot of overhead and most Unity APIs do not work from inside Jobs too.

    As for MiRROR it is on the way with release of V2 which I am in testing phase at the moment. Had a few setbacks (looking at you Unity and your buggy SerializeReference attribute) but the update is getting closer and it is getting better with each day.
     
    chrisk likes this.
  13. sonicviz

    sonicviz

    Joined:
    May 19, 2009
    Posts:
    1,046
    Any progress on release date?
     
    krou likes this.
  14. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,630
    End of this month is still estimated release date for beta. Only feature left to implement is Mirror support but everything else is there. A lot of testing to do to make sure the asset is relatively bug-free on release.
    Unity's implementation of [SerializeReference] was anything but bug-free which did set me back a few days and one critical bug fix is still expected for 2019.3.0f7 which will most likely be the minimum required version.
    I really wanted to make 2018.4 LTS the minimum required but 2019 has brought with it a lot of useful features and the SerializeReference attribute in question which is used for module system:

    upload_2020-2-5_11-31-19.png

    Modules are NOT Monobehaviors but do act similar.
    All the functionality that is not required in the base module has been moved to modules.
    Modules are fast and easy to make and there will also be an empty module template for those that want
    to make their own. This will solve a lot of problems where adding more features to the asset would actually slow the asset for those that do not need those features, make code a lot cleaner since each module is in the different namespace and does not reference other modules which in turn helps with debugging, make sure that changes that people make to the asset do not get overwritten each update and so on.
     
    Last edited: Feb 5, 2020
    GLID3R82, mthawley, Freznosis and 3 others like this.
  15. sonicviz

    sonicviz

    Joined:
    May 19, 2009
    Posts:
    1,046
  16. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,630
    There will be an update of Wheel Controller to V2 in a few days time.
    This version will be used in NWH Vehicle Physics 2.
    You can see more about it here.
    • No creeping on slopes (video in the link above).
    • Better friction calculation.
    • Performance improvement of ~30%.
    • New custom editor (screenshot in the link above).
    • Friction settings are now solved inside FrictionPreset scriptable objects and allow for adjusting of curve parameters with realtime preview.
    • Many more general code improvements, etc.
     
  17. DeathRace26

    DeathRace26

    Joined:
    May 26, 2019
    Posts:
    75
    Thanks so much for the creep fix, i made myself one some time ago, based on speed. This is way more better :D
     
  18. mthawley

    mthawley

    Joined:
    Sep 7, 2018
    Posts:
    100
    Hi. I have noticed that during gameplay the wheel controller sometimes moves away from the centre of the wheel as shown below;



    Any ideas on what could be causing this? Cheers.
     

    Attached Files:

  19. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,630
    I am going to guess that you were moving when that shot was taken. This is just a result of FixedUpdate() and OnDrawGizmos() being ran at different update intervals and gizmos lagging by a bit behind the actual physics - so it is just the gizmo, not the entire wheel.
     
  20. mthawley

    mthawley

    Joined:
    Sep 7, 2018
    Posts:
    100
    Ok thanks.
     
  21. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,630
    Development preview 2 is out if anyone is interested.
    Here is the link. Win64 only.
     
  22. Barritico

    Barritico

    Joined:
    Jun 9, 2017
    Posts:
    366
    Thanks!!!!
     
  23. Hoonbag

    Hoonbag

    Joined:
    Jul 18, 2017
    Posts:
    14
    amazing work mate, will v1 update auto throw the asset store im very keen !!
     
  24. thedetective456

    thedetective456

    Joined:
    Oct 1, 2019
    Posts:
    35
    Hey @nwheelercoc can I get that truck model. I am working on a vehicle physics. For my game, but I didn't find a good trick with trailer anywhere.... Just for testing purposes:D
     
  25. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,630
    Truck model is included with the asset so it will be in the models folder or you can get it from GR3D on Asset Store who provided the model.
     
  26. Anhella

    Anhella

    Joined:
    Nov 18, 2013
    Posts:
    67
    Good day
    does anyone know how to stop the car from flipping over after colliding into a prop or player with a rigidbody?
     
  27. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,630
    Hello,
    if the vehicle jumps/flips when it hits an object by the side of the wheel you most likely will be able to solve this by using the rim collider option inside WheelController inspector. Otherwise making the body collider cover the wheels to some extent helps.
     
  28. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,630
  29. siumanchun

    siumanchun

    Joined:
    Apr 7, 2013
    Posts:
    44
    Hi !
    NWH Vehicle Physics 1.9.4
    And
    NWH Vehicle Physics 2
    Support Unity 2017.4.11f1 ?

    Please Add Video tutorial !

    Thank You !
     
    Last edited: Feb 20, 2020
  30. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,630
    Hello,
    to be able to use NWH Vehicle Physics 1.9.4 you will need Unity 2018.3. Unity 2017.4 is also supported but the version is not as recent.
    NWH Vehicle Physics 2 will require Unity 2019.3.1 due to [SerializeReference] attribute being used for module system. I am aware that this might be a problem for some developers but 2019 LTS version is nearing closer and 2019 is more and more stable with each release.
     
  31. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,630
    One question for users of NWH Vehicle Physics 1: What is your biggest issue/gripe with vehicle setup process?
     
  32. nemeth-regime

    nemeth-regime

    Joined:
    Feb 13, 2017
    Posts:
    39
    Hey I have not used this asset in some time but when I did use it I could not get a locked diff. Both sides of an axle would still turn independently some what. Was there something I was missing or is there any changes to differentials in V2 that would make the rotation of both wheels/sides of an axle always be in sync with each other?
     
  33. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,630
    You are correct. One more reason why a new solver was needed. V1 uses single tick per frame while the new solver uses anywhere from 8 and upwards. You can in fact make it so tight that you get problems steering as all the wheels attempt to rotate at the same speed so one of them has to slip. The stiffness is configurable in V2 so you can go from open to fully locked and anywhere in between. Perfromance of the asset has gotten better despite the substepping.
     
  34. nemeth-regime

    nemeth-regime

    Joined:
    Feb 13, 2017
    Posts:
    39
    That is good to hear. I look forward to using V2 when its released.
     
  35. obstudio

    obstudio

    Joined:
    Sep 30, 2016
    Posts:
    58
    I would like to see one place where I can temporary override some or all vehicle settings, for example in vehicle with default settings I want on one map to turn off some driving assists, turn off damage and change transmission.
     
  36. iichiversii

    iichiversii

    Joined:
    Nov 23, 2011
    Posts:
    139
    Firstly, I'm really looking forward to the release of version 2, looks great so far.

    To answer your question, the main issue I had with the previous version was that, It was limited with suspension types.
    Now I could be wrong, however, if I am it would be nice to have tutorials on how to set up different types, for example I had a vehicle I wanted to setup with a suspension like in the image below, as you can see the wheels are supported by forward arm type suspensions but I could never find the solution in NWH Vehicle physics.

    2.png
     
  37. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,630
    Since most of the games ma
    Such suspension can be achieved in NVP1. People doing motorcycle and bicycle games have done this by placing the suspension anchor above the wheel and adding the bone od the swingarm as the non rotating object. Issue is that the wheel will travel only up and down and not in an arc.
     
  38. eclipseanu

    eclipseanu

    Joined:
    Jan 6, 2017
    Posts:
    10
    Did anyone found a way to get around this? Apparently only 2 people reported it and after all this time is still happening since is still using the activeTerrain. It blows my mind that so few tried it with multiple terrains.
     
  39. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,630
    I have changed this in V2 to use the hit terrain instead of Terrain.activeTerrain so it sould work fine no matter if 1 or 10 terrains.
     
  40. eclipseanu

    eclipseanu

    Joined:
    Jan 6, 2017
    Posts:
    10
    Oh. More good news then for v2. Is it still scheduled for this month?

    LE: Actually I noticed that is in changelog since 1.9.0, and indeed is not using the activeTerrain anymore, but the one returned by raycastHit. However the error is there whenever I cross terrains.
     
    Last edited: Feb 22, 2020
  41. iichiversii

    iichiversii

    Joined:
    Nov 23, 2011
    Posts:
    139
    I was unaware this was possible in the current version, im not sure what you mean by the wheel will travel only up and down and not in an arc.
    Are there any examples of this put into practice that I can see, would love to know how exactly others did this.
     
  42. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,630
    It is a week behind schedule and that is almost entirely due to Unity, their bugs and me trying to circumvent them. The biggest issue is SerializeReference which came out 8 months ago and at the moment I am debating weather to drop it completely and use MonoBehaviors for modules instead with all the downsides that brings (and work required to make the move) or trust the Unity to fix it in the near future. All the features for the release are done and now I am working on fine tuning, setting up the vehicles in demo scene and improving some areas (from the usability aspect)
     
    iichiversii likes this.
  43. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,630
    When a swingarm moves it pivots around a point in a circle. That is not supported so if you have a short swingarm this will be obvious. But if it is a longer swingarm you can place the WheelController object above the wheel (so the spring is essentially anchored in the air for the photo you posted above) and the arm only moves to follow the wheel position. Will do a drawing if that is not clear enough but I am currently on mobile.
     
    iichiversii likes this.
  44. eclipseanu

    eclipseanu

    Joined:
    Jan 6, 2017
    Posts:
    10
    For me it was the lack of clarity of what each variable does exactly and how much it impacts whatever it should impact. I spent more time googling for vehicle terms and trying to understand how they work than actually using the asset.

    Also the fact that some settings were in multiple places. Like for example ground effects. They're on each wheel, on the car itself and then on the actual ground detection manager. And I totally understand why is it like this but having to go back and forth every time is messy.

    But from what I seen in screenshots and the TO DO doc, I think most were addressed. Gonna come back to this question after I can mess around with v2 myself.
     
    Last edited: Feb 23, 2020
    NWHCoding likes this.
  45. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,630
    I have just uploaded Development Preview 5.
    The focus of this one is race cars in general. I have compared and tuned against Assetto Corsa and Project Cars to weed out the issues and the unrealistic behavior.
    Unity decided to remove the quality selector on builds so I just built it in medium settings.
    Controls are through keyboard with ESC turned on but on low setting.
    Download here (Win64)
     
    nemeth-regime likes this.
  46. iichiversii

    iichiversii

    Joined:
    Nov 23, 2011
    Posts:
    139
    I think I understand it now, something I will try out on V2, thanks for that.

    Also, I am curious to know if UTire will be compatible with V2 as it was with V1, or will you have a similar feature build into V2 instead of using UTire?
     
  47. siumanchun

    siumanchun

    Joined:
    Apr 7, 2013
    Posts:
    44
    One question for users of NWH Vehicle Physics 1: What is your biggest issue/gripe with vehicle setup process?
    1. NWH Vehicle Physics
    Engine and Wheel Setting Value complex , ( very hard ) ! Please improve .
    Switch Automatic, Automatic Sequential and Manual transmission types ! ( very very good )
    Wheel and Physics effect Setting ( very hard Setting to Good effect )
    Minimal of tutorials

    2. Realistic Car Controller 3.3 Engine and Wheel Setting Value Normal ( easy ) !
    Runtime Not Switch Automatic, Manual transmission types ! ( No good )
    Wheel and Physics effect Setting ( No need to edit , Good effect )
    Minimal of tutorials

    3. Edy's Vehicle Physics 5.3 Engine and Wheel Setting Value Normal ( Very easy ) !
    Not Select Manual transmission types ! ( Very No Good )
    Wheel And Physics effect Setting ( No need to edit , Good effect )
    Minimal of tutorials
    Thank You !
     
    Last edited: Feb 23, 2020
  48. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,630
    Somebody asked about locking differentials. Here is the video.

     
    Freznosis, xDeveloper and iichiversii like this.
  49. Freznosis

    Freznosis

    Joined:
    Jul 16, 2014
    Posts:
    294
    My 2 biggest problems with NWH.

    1. Differentials - This was already addressed by you because of no substepping, which makes sense. So I won't write anything about this since you've already fixed this.

    2. Collisions - Or lack there of. The core problem isn't necessarily your fault, because physics in Unity seem to be very wonky out of the box. They need some processing to really get a good feel to them. So while this is a core problem with Unity, other vehicle assets try to provide remedies for this sort of thing. Off the top of my head, I believe EDY's VP and RCC do some kind of collision handling magic to stop various problems from happening. Getting stuck on terrain, suddenly stopping on road bumps, getting stuck on walls, sharp edges are a pain to deal with in general. I'm not an expert on collisions though, so I have no idea what other vehicle assets are doing. But it might be worth looking into as I've noticed this in your NWH VP trailer also. I had researched about this a while ago and I read that Unity was supposed to add a way to react to your own collisions right? I have a feeling it is only for the new ECS based physics systems though.

    There are some other things I wanted to mention but I don't remember. I'll get back to you when I remember.
     
  50. nemeth-regime

    nemeth-regime

    Joined:
    Feb 13, 2017
    Posts:
    39
    Great work on the latest dev preview. Comparing it to Assetto and Pcars I would say there is a little too much grip when the tires lose traction. For example when the backend comes out the power gets bogged down and if you spin the car then it comes to a stop too quickly. I am guessing the parameters can be changed to address this though. Apart from that I am really liking this so far.