Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

NWH Vehicle Physics 2

Discussion in 'Assets and Asset Store' started by NWHCoding, Apr 8, 2020.

?

What would you like to see implemented next?

Poll closed Feb 12, 2023.
  1. FMOD sound module

    0 vote(s)
    0.0%
  2. Tracked vehicles

    3 vote(s)
    30.0%
  3. Softbody wheels

    7 vote(s)
    70.0%
  4. Something else (mention in the thread)

    0 vote(s)
    0.0%
  1. yuezhicheng123

    yuezhicheng123

    Joined:
    Jul 14, 2020
    Posts:
    4
    Hi, do you develop motorcycle module based on NVP2? And I understand motorcycle module just like flip over module, speed limiter module included in NVP2, is that right?
    Is it possiable to develop the motorcycle module based on NVP2?
     
    Last edited: Jul 14, 2020
  2. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,685
    Hello, that is correct. It will be a same type of module as the other modules you listed and it will add functionality to NVP2. But it will also be more than that since it will come with its own models, sounds, etc. Motorcycle module will be a paid addition due to the scope of it with a price in the $20 range.
     
  3. Ward101

    Ward101

    Joined:
    Mar 22, 2016
    Posts:
    52
    Hi! What's the status for tracked vehicles? Do you have plans to add as a module?
    Just some context .. I've been using version 1 for a while for heavy machines simulation (like excavators), among other wheeled.
    I'm planning a future migration to version 2. But would like to know if there're plans to include tracks.
    Thanks!
     
    Last edited: Jul 18, 2020
    jirkach likes this.
  4. IceTrooper

    IceTrooper

    Joined:
    Jul 19, 2015
    Posts:
    35
    Hey, the asset looks really promising. I got three questions:
    1. Is it possible to achieve Motorstorm-like vehicle behavior? Dynamic movement, lots of jumps with vehicle, etc. I didn't see any video on how the vehicle in the air for a longer time look like with your asset ;p
    2. Is it enough optimized to use on mobiles?
    3. Is it possible (and easy) to achieve an arcade-style vehicle movement?
    Thank you for your reply!
     
  5. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,685
    Hello,
    Here are the answers:
    1. Steering in air is not possible. This asset aims more towards Project Cars 2 than towards GTA V. That said, applying brakes in air will apply correct torque (same for spinning up the wheels) so you can control the pitch of the vehicle to some extent while in air. This calculation is physically accurate so no crazy arcade-style flips or anything like that.
    2. Yes. The mobile demo scene has an example setup with lower resolution textures and particles. Through the state system (http://nwhvehiclephysics.com/doku.php/NWH/VehiclePhysics2/StateSettings) it is also possible to disable all the unused components. The asset has been made with performance and mobile users in mind.
    3. This is a complicated one. The asset aims to be realistic. All the calculations aim to be as physically accurate as I can get them (without sacrificing performance): tyre mode, powertrain, suspension, etc. It is not primarily made to be used in games such as NFS Most Wanted or GTA V. These have much different approach to vehicle physics and do not care about physics most of the time. So I would say you could get it half there just trough adjusting settings (namely friction) but to get it to feel exactly like NFS Most Wanted you would need to make a lot of user assists (e.g. it is nearly impossible to spin out in that game and they skillfully managed to get the player feel as if they are doing that, not a ton of assists that are running in the background.
    Hopefully this helps. Tried to be as realistic as possible.
     
    Last edited: Jul 18, 2020
  6. yuezhicheng123

    yuezhicheng123

    Joined:
    Jul 14, 2020
    Posts:
    4
    I am confused that if ESCModules works. Although ESCModules add the break torque to the wheel, brakes's FixedUpdate run before moduleManager's FixedUpdate In VehicleController.cs. I think it doesn't work.
     
  7. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,685
    Hello,
    I will investigate this for the upcoming update. Added to Trello.
    Although keep in mind that WheelController's friction is calculated using a function call from VehicleController's Powertrain to ensure execution order and not WheelController's FixedUpdate.
     
  8. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,685
    Okay, here is a test build for the new longitudinal friction. I think it transformed the way the vehicle handle, but would suggest trying it out for yourselves. Note that static friction is not yet implemented and that the vehicle might behave a bit weird at very slow speeds but the higher speed stuff is all done. Stiff rear differential + throttle will actually result in oversteer instead of understeer as @Sopcen#5013 noticed. The Lada setup in the scene has 200kW and solid rear diff combined with manual transmission - get it into the second gear and burn that rubber :) https://drive.google.com/file/d/1-M4Pvpf4UlZS1JcnVoLQxo5JyYGDrQ71/view?usp=sharing
     
    Last edited: Jul 26, 2020
  9. fredastaire

    fredastaire

    Joined:
    Sep 10, 2017
    Posts:
    90
    Hello

    this may be an odd question but I’m trying to get your physics system to work with ml agents and not sure how to write the hueristic inputs for the car any help would be great
     
  10. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,685
    Unfortunately I have never used ml agents and have not done much AI yet so I can help only one the NVP2 side of things. If you do need help with setting inputs to the vehicle from the AI or something similar I can help there.
     
  11. fredastaire

    fredastaire

    Joined:
    Sep 10, 2017
    Posts:
    90
    That is where I’m having issues I can’t figure out how to have the ai access to steering throttle and brake I’m using the new inputs system and input.getaxis(“horizontal”); and input.getaxis(“vertical”); don’t move the car.

    Is there a namespace or using (system); that I need to reference to send inputs to the physics system?
     
  12. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,685
    Please check the docs on this, esp. the last section: http://nwhvehiclephysics.com/doku.php/Setup/Input
     
  13. Havok_ZA

    Havok_ZA

    Joined:
    Jul 27, 2016
    Posts:
    69
    Any A.I asset you would suggest using with this for A.I vehicles?
     
  14. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,685
    As mentioned above unfortunately I have not worked much with AI, and not at all in the field. There were some customers mentioning using different AI solutions on Discord so maybe you could pop in there and ask (link in description). I have AI on the roadmap for the future but as of this moment unfortunately I can not help much. The input in NVP2 has been designed so that it is easy to link AI output to NVP2 so most AI packages should work (if they work with vehicles in the first place).
     
    Davidbillmanoy and Havok_ZA like this.
  15. unity_AITsXfcCstDDyg

    unity_AITsXfcCstDDyg

    Joined:
    Jun 13, 2018
    Posts:
    1
    Hi. How can I increase the power of the engine? I want to make a car climb up the hill, but the engine with a basic setting is too weak. I increased Max Power value in Engine setting, but it seems like not working what I intended.
     
    Last edited: Jul 29, 2020
  16. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,685
    Hello,
    This question comes up a lot but here are the answers:
    - Increasing engine power. Vehicle will accelerate faster and have more torque but this does not guarantee being good at hill climbing. Having a 1000hp car does not make it good at hill climbing.
    - Increasing transmission ratio. If you do not want to increase power you can instead increase final ratio of the transmission. This will give you more torque at the wheels.
    - All that will not help if you do not have enough grip. If you experience wheel spin on hills you need more traction and the above two will not give you any more traction than you have, no matter how much you increase the power. In this case try increasing "Max Tire Friction Force" value progressively (e.g. 10% at a time) until you are happy with the result. This will change the friction across all surfaces. If you want to change friction for one surface only (e.g. grass) modify the FrictionPreset for that surface.
     
  17. yuezhicheng123

    yuezhicheng123

    Joined:
    Jul 14, 2020
    Posts:
    4
    I want to develop motorcycle by myself, and you said the key point is to keep the motorcycle's balance. Is it possible that adding RigidbodyConstraints.FreezeRotationZ to the vehicleRigidbody keeps the motorbike's balance?
     
  18. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,685
    The answer is no. You can try but the results will be a motorcycle that always stays perfectly upright, without any leaning. And constraints are not completely 'frozen' meaning it will still rotate over time.
     
  19. yuezhicheng123

    yuezhicheng123

    Joined:
    Jul 14, 2020
    Posts:
    4
    In reality, the body of a motorcycle will lean along forward dirction( Z axis in unity) when it turns. After I add FreezeRotationZ to the vehicleRigidbody, I rotate the vehicleRigidbody along Z axis. So motorcycle is not completely 'frozen' .
     
  20. fredastaire

    fredastaire

    Joined:
    Sep 10, 2017
    Posts:
    90
    I’ve read your documentation for inputs still fuzz to me

    is the steering controller using horizontal or steering for the state I need to call for ai

    also with throttle and brake

    is the example line myVehicleController.input.states
    how I need to write the ai or is it just “whatmycontroller”.input.state is?
     
  21. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,685
    So say your AI gives a steering result called "steeringAIValue" and you wanted to apply that values to a vehicle.
    So you would do is:
    myVehicle.input.autoSetInput = false; // Disables input fetching. While this value is true inputs from InputProviders will be ignored and input can be set manually.

    myVehicle.input.Steering = steeringAIValue; // Sets the steering values

    Where myVehicle is
    VehicleController
    component attached to your vehicle.

    Normally vehicles get their input from active InputProviders (an interface between input method and a vehicle). When you set autoSetInput to false you can set the input states/values manually instead since InputProviders will effectively get ignored and you do not have to worry about your manually set values being overwritten. Hopefully this makes it clearer.
     
  22. fredastaire

    fredastaire

    Joined:
    Sep 10, 2017
    Posts:
    90
    Thank you that helped a lot.
     
  23. fredastaire

    fredastaire

    Joined:
    Sep 10, 2017
    Posts:
    90
    If anyone wants to use ml agents for their ai I was able to make the agent script interface with nwh physics.
     
    Willbkool_FPCS and GLID3R82 like this.
  24. vit-ryska

    vit-ryska

    Joined:
    Feb 10, 2015
    Posts:
    1
    Dear NWH,
    I have been using the first edition of the asset to simulate tracked vehicles (like tanks etc.). Please do you plan to add the support for tracks to this new edition ?

    I would appreciate any response.
    Thank you in advance
     
  25. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,685
    I very much do, and at a higher quality than in v1 but this will not happen in the next few months as I have two updates in queue and the motorcycles module has the priority at the moment since it won in the poll by a lot.
     
    vit-ryska and Willbkool_FPCS like this.
  26. bebo77

    bebo77

    Joined:
    Aug 3, 2012
    Posts:
    84
    Hi,

    Does anyone have a problem with physics in Unity 2018.4.23? o_O

    The vehicle vibrates a lot even when stationary, you can see it a lot with the interior chamber.



    If I put IsKinematic it stops.
    you can check it and possibly update it, because then it's not usable... Thank you.

    P.s I haven't modified anything.
     
  27. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,685
    Hello,
    if anyhow possible update to NVP2 v1.2.x (requires Unity 2019.3+). Unity 2019.4 LTS has been already out for some time so that would be my first suggestion.
    Secondly, try setting Project Settings > Time > Fixed Delta Time to 0.016667. This will help a bit and also increase the physics fidelity.
    This is not the expected behavior and should be fixed in newer versions.
    So please try to update and see if it helps. Since you have not started work on the project a clean import would be the best solution due to the number of changes.
     
  28. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,685
    A new test build for v1.3 is up and this is very close to what the final release will be.
    The focus of the update is friction. It has taken quite some time to get it where it is in this build but it has been more than worth it. One thing that is not implemented in the demo but will be in v1.3 is blips on downshifts which, due to the way more realistic friction model, is required (at the moment aggressive downshifts while cornering will cause the car to spin out since it just 'rams it into gear' without matching the revs causing the rear wheels to lock up).

    Here is the link, input would be great: https://drive.google.com/file/d/1-M4Pvpf4UlZS1JcnVoLQxo5JyYGDrQ71/view?usp=sharing
     
    GLID3R82 and dsilverthorn like this.
  29. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,685
    I have just added rev-matching to the test build above so the shifts are much smoother now and do not result in rear end kicking out on the sports car.
    Needs a few more hours of testing and v1.3 will be pushed to the Asset Store.
     
    GLID3R82 and dsilverthorn like this.
  30. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,685
    v1.3 beta is ready if anyone wants to try it out. It should be out ~Tuesday (August 18th).

    Changes:
    • Major improvements to tire friction calculation.
    • Improved vehicle inertia tensor calculation, existing results were on the low side.
    • Added new Ackerman steering calculation for 4-wheeled cars. Other vehicles still use the old, linear, calculation.
    • Eliminated WheelController creep in longitudinal direction.
    • Fixed vibration when standing still with vehicles that had large wheel mass.
    • Improved Cruise Control by adding “Deactivate On Brake”.'
    • Fixed a bug with powertrain that resulted in engine being too hard to stall.
    • Fixed FrictionPreset not saving changes once the project is reloaded.
    • Fixed 'flipInput' option in SteeringWheelProvider to flip input from [0,1] to [1,0] instead of [0, -1]
    • Fixed issue with VehicleSetupError where it would throw a cast error if 'Add Cameras' is enabled.
    • Fixed CameraInsideVehicle not registering (bug from 1.2.0).
    • Fixed InputSystem input not resetting after scene reload.
    Latest test build (Win64) is here.
     
    csummers88, GLID3R82 and dsilverthorn like this.
  31. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,685
    v1.3 has been submitted to the Asset Store and will be available in 2 to 3 days.
     
    Mixa1985 and csummers88 like this.
  32. bebo77

    bebo77

    Joined:
    Aug 3, 2012
    Posts:
    84
    Great!
     
  33. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,685
    Please report any bugs if you come across any. I have spent a lot of time test importing and trying to break things but the customers are always better at that :D
     
    GLID3R82, paljoci and Willbkool_FPCS like this.
  34. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,685
    Update v1.3.1 is on the way with the following changes:
    • Stiffer lateral friction.
    • Fixed SteeringWheelInputProvider error due to missing variable. Introduced in v1.3.
    • Fixed VehicleSetupWizard failing when there are no InputProviders in the scene.
    • Fixed vehicle input not initializing when there are no InputProviders in the scene.
    • Fixed issue with vehicleRigidbody being null during VehicleSetupWizard setup causes errors.
     
    GLID3R82, csummers88, paljoci and 3 others like this.
  35. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,685
    v1.3.1 has to be resubmitted due to some asset policy changes so here is the new changelog:
    • Implemented proper spring bottom out calculation.
    • Stiffer lateral friction.
    • Lada Niva model is now commercially licensed and no longer CC-BY (as required by Unity).
    • Added mouse input option to both InputSystem and InputManager VehicleInputProviders.
    • Fixed some textures having different native resolution and Max Resolution set in inspector.
    • Fixed error with manual transmission when trying to shift into non-existing gear. Error introduced with rev-matching in v1.3.
    • Fixed error while trying to calculate track of vehicles that have only one wheel per wheel group / axle.
    • Fixed VehicleSetupWizard failing when there are no InputProviders in the scene.
    • Fixed vehicle input not initializing when there are no InputProviders in the scene.
    • Fixed issue with vehicleRigidbody being null during VehicleSetupWizard setup causes errors.
     
  36. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,685
    v1.3.1 is live.
     
  37. isNewBird

    isNewBird

    Joined:
    Mar 27, 2019
    Posts:
    20
    Hello, I used the current resource.I want to make the effect of Euro Truck Simulator 2, but I cannot adjust the corresponding feeling all the time, so I feel very troubled.And I adjust out of the vehicle, it will move forward inexplicably shake.I'm asking for your help. Thank you
     
  38. fredastaire

    fredastaire

    Joined:
    Sep 10, 2017
    Posts:
    90
    Hello

    not sure if this is possible but how would I make it so if a car crashes the wheel comes off and the wheel collider goes disabled?
     
  39. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,685
    Hello,
    if you are experiencing any vehicle shaking more than likely your vehicle inertia is off. Go to Vehicle Controller > Settings and verify the the entered dimenstions are correct. After that click "Calculate Center of Mass" and the same for inertia.
    I would also like you to check that you have version 1.3.1 (Unity 2019.3.) required.
    Might I ask what "corresponding feeling" means as it seems to be lost in translation.

    Regards,
    Aron
     
    isNewBird likes this.
  40. isNewBird

    isNewBird

    Joined:
    Mar 27, 2019
    Posts:
    20
    Hello, I mean I want to tune up the driving touch of a Euro Truck Simulator 2. Do you have a good suggestion?May I ask if the middle shift jitter can be turned off?Some players don't like the feeling.I think when I start, like Euro Truck Simulator 2, I will start slowly, but this will affect the vehicle climbing. Is it possible to start slowly and ensure the ability to climb?thank you
     
  41. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,685
    Since most users use keyboard input this is a bit tricky. Normally, nobody drives with the pedal to the floor all the time but in keyboard users case this is exactly what is happening.
    There is an option for throttle smoothing built in under the Powertrain > Engine but this will give you just a small ease-into throttle (in case you want values outside of the range of the slider just change the Range attribute for that field in Engine.cs). Playing with engine power curve could also help a lot.
     
  42. isNewBird

    isNewBird

    Joined:
    Mar 27, 2019
    Posts:
    20
    Thank you very much!

    The translation I use is like S***.I'm very sorry for the inconvenience.

    1. I will try to adjust the driving touch, thank you.

    2. I also want to know how to get rid of the jitter when switching gears.thank you
     
  43. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,685
    Hmm, jitter? Reducing the transmission shift time to near zero will help with this as there will not be a period when the wheels do not receive power. If you are using v1.3.1 there will also be rev-matching option under transmission which will help.
     
    GLID3R82 likes this.
  44. isNewBird

    isNewBird

    Joined:
    Mar 27, 2019
    Posts:
    20
    Hello, thank you for your help.As I mentioned last time, slow speeds can go uphill. Do you think you could add a ramp power system?It's a slope that you can't climb up, and when you turn on the system, you force a speed, and you slowly climb up, right?Hard to you
     
  45. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,685
    Well, there is such a system in place already.
    You will see the incline option under the Powertrain > Transmission tab and what this does is force a lower gear on inclines effectively giving the vehicle more torque to the wheels. Since I aim for physical accuracy I refrain from 'magic' solutions and downshifting is exactly what trucks do when they encounter and incline.
     
    GLID3R82 likes this.
  46. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,685
    Update v1.3.2 is on the way:
    • Fixed bottoming out force impulse and added damping to prevent vehicles from * excessive bouncing after bottoming out hard.
    • Added gizmos to display vehicle dimensions.
    • Added PUN2 demo scene.
    • Added Mirror demo scene.
    • Tuned up inertia calculation.
    • Updated demo vehicles for better handling.
    • Fixed flipped mirror UVs on Lada Niva.
    • Fixed issue with skidmarks sometimes using a wrong material.
     
    Mixa1985 and csummers88 like this.
  47. mthawley

    mthawley

    Joined:
    Sep 7, 2018
    Posts:
    104
    Hi. I would like to run an idea passed you which I think may be helpful to a lot of developers using your product. Would it be possible, when setting up a vehicle, to have a dropdown of vehicle types (templates) that would provide a basis for the developer to start customising the vehicle?

    For example if I am setting up a Dune Buggy, I could select an Off-Road template which would provide the typical values for that type of vehicle. The template would provide typical values for suspension, gearing, transmission etc.
    The template list needn't be too exhaustive, say Off-Road, Sports, Racing, Truck, SUV etc.

    I think this could be really useful for those of us who struggle with setting up different vehicle types due to a lack of knowledge of these technicalities.
    Cheers.
     
    dsilverthorn likes this.
  48. mthawley

    mthawley

    Joined:
    Sep 7, 2018
    Posts:
    104
    Could you please provide an explanation of how/when the VehicleComponent LOD states are used? Are the LODs the same as typical LODs in that they are applied dependent on distance from the player? This sounds promising for AI cars to use less resources during gameplay.
     
  49. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,685
    That is exactly what they are and they work based on distace from camera. Since a vehicle is composed of a bunch of VehicleComponents, each of them can be disabled or enabled based on the distance from player.
     
  50. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,685
    Actually, I just mentioned this idea a few days ago in Discord. I am going to put some work in the wizard so that it ends up with a more useable vehicle rather than the same setup for all of them which then requires a lot of tweaking.
     
    dsilverthorn likes this.