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. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,683
    An update is on the way and should be live within a few hours. Clean import recommended.

    v1.8.0


    23/05/2022
    • Added MotorcycleModule.
    • Added ArcadeModule.
    • Added AirSteerModule.
    • Improvements to powertrain ClutchComponent and DifferentialComponent.
    • NRigidbody improvements.
    • Overall vehicle handling improvements and tweaks.
    • Replaced substep count selector with Physics Update Rate field in [Hz].
    • Replaced ClutchLSD and ViscousLSD with single LimitedSlip option. Viscous slip has been replaced with VLSD_Obsolete_Placeholder and will point to the new LimitedSlip.
    • [WheelController] Improvements to the WheelController resulting in higher high speed stability and overall improved handling.
    • [WheelController] Removed SingleRay option and instead replaced it with possibility to use minimum longitudinal scan resolution of 1 (previously 3).
    • [WheelController] ~20% performance improvement.
    • Many other small changes, tweaks and improvements.
     
  2. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,683
    An update is on the way:

    v1.8.3


    08/06/2022
    • Fix ReorderableList being drawn wrong in latest Unity 2021 versions (known Unity bug).
    • Fix for lateral friction creep when vehicle is stationary on flat ground, introduced in v1.8.0.
    • Clutch variable engagement is now throttle dependent.
    • Increased default clutch engagement speed (by 3x) to avoid stalling on hard braking.

    I have reverted the ReorderableList code to what it was about half a year ago due to the newly introduced ReorderableList bug by Unity. Unity seems to have since fixed the bugs that caused the issue at that time.
    Unity 2020.3.8f1, latest 2020 and 2021 LTS are all now having ReorderableList drawn properly.
     
    Willbkool_FPCS and SalihMucahit like this.
  3. kyk4

    kyk4

    Joined:
    Apr 23, 2019
    Posts:
    2
    Is it possible to somehow block the course of the body, it is required since I use large values of downforce to drive vertically ?
    upload_2022-6-8_19-10-15.png
     

    Attached Files:

  4. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,683
    Not sure what the course of the body would be but male sure that you have adequately strong suspension that can deal with the downforce.
     
  5. kyk4

    kyk4

    Joined:
    Apr 23, 2019
    Posts:
    2
    The increase in "MaxForce" solves the problem with the failure of the body, but the car starts jumping like a ball at any irregularity. It is not possible to configure the Wheel Controller so that it is acceptable with a large downforce.
     
  6. Zubair_Malik907

    Zubair_Malik907

    Joined:
    Jun 19, 2019
    Posts:
    15
    Hello. I'm new to unity.
    I wanted to increase the engine running sound. I changed the master volume of audio mixer to 2 but that's not enough.
    Sound get overpitched when I change Engine component of audio mixer.
    Any help would be appreciated.
     
  7. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,683
    It is. If you increase the spring rate by 50%, also increase the damper settings. Also, if you have downforce of 4000 on the front, that is 2000N per wheel. So increasing the spring force by that amount should be about adequate. Jumping will only happen if the values are wildly unrealistic, there is no damping at all, etc.
     
  8. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,683
    You can adjust all the sounds through VehicleController > Sound tab. Also, I would recommend normalizing the spunds in Audacity or similar software for easier setup.
     
  9. claudius_I

    claudius_I

    Joined:
    May 28, 2017
    Posts:
    251
    Hello, to the motorcycle module will be add a character or always be a motorcycle alone?

    Thanks
     
  10. TokyoWarfareProject

    TokyoWarfareProject

    Joined:
    Jun 20, 2018
    Posts:
    812
    I think having an assists module to be enabled when players uses gamepad would be a huge addition. Then every dev tunes it per car or per project. But as it is, with the current sensitivity curves I'm having a hard time tweaking any fast car for a gamepad.
     
  11. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,683
    I have not been planning on adding a character, mostly due to the fact that I am limited to the tools that are included with Unity for achieving this, and that animation is not my field. However, there are a lot of 3rd party IK and other tools that should be able to get a decent result.
     
  12. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,683
    The curves are pretty much what most driving games expose (sensitivity, linearity, smoothing) and the implementation of this is quite simple. A lot of AAA games actually have AI or otherwise assisted steering, braking, etc.
    One tip: when dealing with high speed vehicles using higher physics update rate (Settings tab) or lower Time.fixedDeltaTime can be very helpful in getting the feel of the vehicle right and stable.
     
    TokyoWarfareProject likes this.
  13. Slashbot64

    Slashbot64

    Joined:
    Jun 15, 2020
    Posts:
    300
    Why does is the demo scene so awful? like the mouse jitters, and you don't have have the very basic cursor locking code added so that the mouse stays in the gameview where we can just press [esc] to unlock it, ...it should be like the most mandatory thing for any asset sold in the store to provide for demo scenes.... frustrating demo scene for sure. Did you just test this on console or something?
     
  14. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,683
    Thank you fornthe feedback, there is no cursor locking which is something I left so it is easier to navigate the buttons but your idea is good and I will look to implement it woth the update. I have not encountered any mouse jitters on my hardware so thank you for pointing out that this is an issue.
     
  15. fredastaire

    fredastaire

    Joined:
    Sep 10, 2017
    Posts:
    90
    Is there more documentation on the rigging module the website doesn’t match what the in game module looks like and not sure how to rig a car?
     
  16. MatheusPereiraBarros

    MatheusPereiraBarros

    Joined:
    Feb 21, 2015
    Posts:
    10
    Hello, NWHCoding

    Is it possible to add a bus as prefab in future asset updates? Bus prefab is present in NWH 1 demo scene, but, no more in NWH 2.

    Best regards!
     
  17. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,683
    There is a semi truck that is configured identically to the bus, just has a different shape. There is also a VehicleSetupWizard that allows automatic setup of the vehicles. Due to the setup similarities I did not include the bus this time, but may be a good idea to re-consider to the amount of requests for it.
     
    Last edited: Aug 10, 2022
    MatheusPereiraBarros likes this.
  18. QuynhnhuMac

    QuynhnhuMac

    Joined:
    Dec 20, 2021
    Posts:
    1
    I have just added the component VehicleSetupWizard to my car, but there is many errors in console.
    NWH version 1.6.2 and Unity version 2021.3.1. Help me, please!
    upload_2022-8-11_23-8-26.png
     

    Attached Files:

  19. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,683
    You have an older version of the asset. Make sure to update to the latest version (v1.8.x) as there has been a bug introduced recently in Unity - which I fixed in the meantime. Not even sure where you got the version since it is not available on the asset store.
     
  20. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,683
    For the upcoming update, among other things, there have been major changes in the multiplayer implementation.
    Most of the multiplayer logic (related to setting/getting the vehicle state) has been moved to the VehicleController class itself and the whole network state of the vehicle is stored in one struct. That means that any multiplayer scripts (Mirror, PUN, etc.) just have to get that struct over the network and all the work is done.

    A pseudo example:

    Code (CSharp):
    1.  
    2. // Server side:
    3. myNetworkScript.Send(vehicleController.GetMultiplayerState());
    4.  
    5. // ... Send state over the network ...
    6.  
    7. // Client side:
    8. MultiplayerState state = myNetworkScript.Receive();
    9. vehicleController.SetMultiplayerState(state);
    10.  

    This brings the code for Mirror/PUN2 to just a few lines and removes all the clutter, and makes it very easy to implement any 3rd party multiplayer library with NWH Vehicle Physics 2.

    There have also been changes to the sound side of things where the number of sound sources has been cut down by 8 per vehicle and a general sound code clean-up has been done to tidy up things from previous re-factorings.
     
  21. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,683
    v1.9.0 is on the way and should be available within 24 hours.
    Clean import required!

    Changes:
    • Added HDRP guide and particle materials: http://nwhvehiclephysics.com/doku.php/RenderPipelines.
    • Folder restructure and asset cleanup. Clean import required (remove NWH folder before re-importing).
    • Cleanup of audio code: reduced number of AudioSources, moved some sound components to PlayOneShot, changed the way multiplayer sound is synced, general code cleanup and bug fixes.
    • Implemented MultiplayerState - a simplfied approach to multiplayer integration. Rewritten PUN2 and Mirror multiplayer scripts.
    • Added "Realistic" and "Arcade" (legacy) options to Clutch component.
    • Fixed powertrain values assigned after vehicle initialization not getting applied when referenced outside of the Powertrain.Components list.
    • Changed the way "Freeze While Idle" works. Frozen vehicles are no longer simulated which improves performance. Constraints are no longer used - this enables normal use of Rigidbody constraints in combination with "Freeze While Idle" option.
    • Vehicles are now easier to damage by default. Increased wheel wobble on wheel damage and range at which the wheel damage happens.
    • Improvements to forced induction.
    • Fixed issue with VehicleController > PWR tab sometimes causing problems with powertrain.
    • Fixed inverted WheelController.springCompression value.
    • Fixed issue with damaged wheels rotating around Y axis.
    • Overall bug fixes and improvements.
    • [WC] Fixed "applyForceToOthers" being ignored by depenetration force.
    • [WC] Added "Max Load" field. This is the load rating of the tire and it affects how the friction is calculated, amongst other things.
    • [WC] Added camber/friction curve.
    • [WC] Re-introduced "Show Advanced Settings" to WheelController to reduce clutter with the increasing number of settings.
     
  22. Tareq_tsc

    Tareq_tsc

    Joined:
    Aug 19, 2016
    Posts:
    5
    Hello, can the dev clarify what unit of measurement is Nm? (VehicleController/PWR/Engine/Max Loss Torque). Am I right in thinking that it's nanometres?
     
  23. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,683
    All the units in the asset are International System of Units (SI), so in this case the unit is Neton-metre, or imperial alternative is lbft (Pound-foot). I have been quite careful to use SI only to prevent confusion.
     
    Tareq_tsc likes this.
  24. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,683
    Doing some testing for the new product.

     
    khos, ainkiwi, ledshok and 2 others like this.
  25. TokyoWarfareProject

    TokyoWarfareProject

    Joined:
    Jun 20, 2018
    Posts:
    812
    super cool! may be add more polygons to the wheel as is a bit jaggy
     
  26. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,683
    It is adjustable, but still very much a work in progress. Got the mesh working just today. Another quick video:
     
  27. TokyoWarfareProject

    TokyoWarfareProject

    Joined:
    Jun 20, 2018
    Posts:
    812
    This looks amazing. THe only other asset I tested in unity with such level of tyre deformation was CarX which had a remarkable handling. Hopefully this will translate not only into superb visuals but also into a more accurate grip model. (not saying current is bad!)
     
  28. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,683
    Just added a softbody/rigidbody toggle. This allows for a choice between the two. Performance difference at this point is 0.4ms for softbody and 0.06ms for rigidbody tyre, but things can and will be optimized further:

    Animation.gif

    Also, the collision between the wheels works now:
    Collision.gif

    Ignore all the bounce, damping needs some work.
    Everything is running at 50Hz (Time.fixedDeltaTime = 0.02) and the default Physics settings.
    The Softbody Wheel will be gettings its own thread soon here on the forums.
     
  29. creat327

    creat327

    Joined:
    Mar 19, 2009
    Posts:
    1,756
    have you tested this on mobile? I wonder how well it runs on crappy old phones
     
  30. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,683
    Performance with softbody disabled is comparable to the current WheelController. The softbody makes it slower but through a lot of optimization I have been able to get it to something that will be usable even on phones, given that you do not have too many of the wheels. Still too early in development with a lot of placeholder code to give it a good evaluation.

    I just wanted a POC that it can be made to run fast enough for general use. Making a softbody wheel is not that much of an issue - making it run on 50Hz physics update with good performance - quite a challenge. I am currently at ~0.23ms CPU time per softbody wheel, but I believe I might be able to shave it down a bit more. The hard version is at about 0.05ms. But things such as proper friction are not yet implemented.
     
    Last edited: Oct 17, 2022
  31. creat327

    creat327

    Joined:
    Mar 19, 2009
    Posts:
    1,756
    I would use it for 8 cars simultaneously, that means 8x4 wheels. Would that work on old android device?
     
  32. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,683
    Too early to tell, but it would depend on how heavy the rest of the game. I would like to point out that running 8 vehicles with softbody wheels is not the best idea and usually can be avoided since only one vehicle is usually the player vehicle. At the moment there is an option to disable deformation so that could be used for the rest of the vehicles that are not in use or used by an AI.

    Still, this is all in early development and everything is subject to change.
     
    TokyoWarfareProject likes this.
  33. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,683
    Another small update on the softbody wheel. This time multiple of them attached to a mock vehicle, without any suspension.

    SimpleVehicle.gif
     
    ledshok and Rotary-Heart like this.
  34. kopanz

    kopanz

    Joined:
    Dec 6, 2016
    Posts:
    82
    Is this thing still not fixed ? I couldn't see anything in release notes. Tomorrow it's going to be 6 months since my bug report.
     
  35. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,683
    Sorry about that, went through the messages to remind myself of what was being said and I believe all the issues should be resolved so far. In the next update after your message I immediately posted the fix for the trailer not attaching and replied to the message.
    As for the switching between driving forwards and reverse - I have increased the threshold for this. Still, if there is a vibration happening within a vehicle there could be a setup issue. It would be great if you could send the prefab over if it is still happening in the newest version.
    Next, the GC that was mentioned at that point was completely removed. The only remaining GC is from the Unity Terrain function which is internal, with no alternative at this point. However, the amount is in bytes.
    Lastly, there were several performance improvements since v1.7.5, including physics sleep for inactive vehicles. The demo scene is running at ~400FPS on my side at this point at the CPU time dropped from 1ms for the demo scene to under half of that.
    Hope that answers the question.
     
  36. kopanz

    kopanz

    Joined:
    Dec 6, 2016
    Posts:
    82
    Thanks,
    It was for a currently cancelled project but I opened it, updated NWH. After the semi and trailer setup from the wizard, attach on play worked without an issue.
     
    NWHCoding likes this.
  37. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,683
    A few more glimpses into softbody wheel development. I am posting more frequent updates on the Discord (check signature below).

    Tire deformation on cornering:
    Steering.png
    unknown.png

    Collision detection:
    UpsideDown.png

    Performance of multiple vehicles. Most of the physics will be multi-threaded.
    MutipleVehicles.png

    As always, I have to mention that this is still work-in-progress.
     
  38. TokyoWarfareProject

    TokyoWarfareProject

    Joined:
    Jun 20, 2018
    Posts:
    812
    You think the grip would be more realistic? I mean since the surface of contact will be a plane.
     
  39. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,683
    The physics in general feel better already due to the total control over everything since I am mostly not using Unity APIs. A lot of development time on NVP2 was spent getting around black box issues. Too early to speak about the friction but from the testing so far with a very simplified friction model, I am quite happy with the results.
     
  40. kopanz

    kopanz

    Joined:
    Dec 6, 2016
    Posts:
    82
    Did you fixed the trailer Attach on Start problem intentionally ? or it's gone away in time with the changes in script execution order or something other ? As I couldn't see the fix in release notes I began to wonder.
     
  41. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,683
    It was fixed intentionally. Check the message a few after yours original one. And there was some discussion on Discord. Not sure why it slipped the release notes.
     
    kopanz likes this.
  42. Slashbot64

    Slashbot64

    Joined:
    Jun 15, 2020
    Posts:
    300
    when was the last time you tested your demo example? it seems broken like its trying to give me eye cancer... the mouse input seems to jitter everywhere... wasd is fine.. and no mouse cursor lock.. so the mouse goes out the game window making it infuriating to use or test while looking at the inspector... cursor lock should be a basic mandatory thing in demo examples.. its simple to just make a [esc] toggle to for the mouse to use in the inspector while the demo is running and click back in the game window to cursor lock..

    my actual question any future support for unity's netcode for gameobjects?
     
  43. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,683
    About a month ago, gave it a check and there was no jitter at all. Could be different refresh rate monitor causing the jitter. The demo character controller is the standard Unity assets one, nothing fancy. Will try to replicate and fix the issue.

    At the moment Mirror and PUN2 are supported. I went for abstracted approach to multiplayer integration so that is easy to integrate NVP2 with multiplayer libraries - and there are many out there. From what I read it should be similar to previous Unity Networking, of which Mirror is pretty much a clone, so it should not be much work to implement netcode (assuming host+client).
     
  44. Slashbot64

    Slashbot64

    Joined:
    Jun 15, 2020
    Posts:
    300
    well it seems to do be just mouse input.. if I move around wasd there is no jitter... so I don't think its a refresh rate issue

    can you add the mouse cursorlock in future update to the demo scene just a simple thing
     
  45. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,683
    Well, might add a bit of smoothing to solve that.

    The lock was not added so that the UI buttons can be clicked without a need for a modifier key. The demo should be full-screen by default.
     
  46. Slashbot64

    Slashbot64

    Joined:
    Jun 15, 2020
    Posts:
    300
    have you tried adjusting settings in the inspector while the game is still following mouse movement? its the most infuriating thing... espectially when you're trying to adjust the settings for something you actually want visible in the game view.. instead the skybox/ground..impossible to actually, no one has problem using esc to toggle mouse out of the game view// the whole point of the demo scene running in the editor is a way to check the asset out and tweak things in the inspector on a existing scene that is setup with vehicles configured ... anyone running that in the fullscreen might aswel just download the existing compiled demo
     
  47. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,683
    Noted.
    The point of the demo is that it is compiled. The source code is only available to the customers.
     
  48. TokyoWarfareProject

    TokyoWarfareProject

    Joined:
    Jun 20, 2018
    Posts:
    812
    This is how Unity works, you could try to write a serializer so after you tweaks things in runtime to your liking in many areas, you can save to a file. A trick I do sometimes with simple script is to copy component in runtime, and after runtime simply paste values. Since this asset has a complex ui may not work, I've not tried doing.
     
  49. Slashbot64

    Slashbot64

    Joined:
    Jun 15, 2020
    Posts:
    300
    That's not what complaint about the lack of cursor lock script being added is about... anyway to your point I'd recommend using something like copy component https://assetstore.unity.com/packag...pboard-copy-n-paste-multiple-components-50686 -then can copy paste multiple things from that back to the original after ending playmode.

    I think there is a free version.. and some other addons do similar.. should be built in .. not really a NWH thing.
     
  50. markoal

    markoal

    Joined:
    Aug 31, 2015
    Posts:
    30
    I just tried using this plugin, and tried setting up steering wheel. I have a Thrustmaster T500. I expected things to be easy as setting up correct input in new input system. But I didn't manage to get it right. Then I tried your steps, downloaded Logitech SDK and used steering input that have some weird predefined enums inside (like X Position, Y Position). The only thing I have working is steering. Shifter, throttle, break, clutch, buttons are not working at all, I tried giving throttle using keyboard just to see how it looks like, but it doesn't work like that.
    It's not big deal for me as I tried it for fun. However, even thought I might be missing something fundamental here, still it should be more straightforward.