Search Unity

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,692
    The biggest issue here is different bindings between the different wheels. I only have a Logitech G29 which has the same bindings as most of the other Logitech wheels and as such there is a SteeringWheelVehicleInputProvider prefab made for it included with the asset and should work out of the box for all the bindings / settings. Thrustmaster should work too but requires re-mapping the axis/buttons. If I had one to test on, I would make a prefab with the binding already set for it too. On Discord there are a few people that use it with Thrustmaster so it can be done.
    To help with the setup, the buttons that are pressed and the axis that are moved should be visible in the Logitech debug UI. From there they can be copied into the inspector of the input provider. Really sorry about the complications and issues. There is really a glaring lack of standardization between the steering wheel manufacturers.
     
    markoal likes this.
  2. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    Both NWH Vehicle Physics 2 and Dynamic Water Physics 2 are 50% off at the moment.
    Check the links in the signature for the assets in question.
     
  3. NWHCoding

    NWHCoding

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

    ==== v1.9.4 ====
    == 23/11/2022 ==
    * Added top speed per gear display to transmission inspector.
    * Reduced minimum powetrain inertia range.
    * Fixed steering not un-freezing the vehicle.
    * Fixed emissive mesh lights not working with HDRP.
    * Fixed ArcadeModule not checking if vehicle is fully grounded.
    * Fixed trailers not unfreezing with the towing vehicles.
    * [WheelController] Fixed friction force coefficients being applied before slip circle, resulting in unrealistic behavior on slippery surfaces.
     
    ledshok likes this.
  4. NickM48

    NickM48

    Joined:
    Jan 17, 2017
    Posts:
    5
    I've only just purchased your Vehicle Physics 2 and within half an hour I had removed my own vehicle physics code from my game and replaced it with yours, it was so easy to set up, works great and will save me a ton of time.

    I just wanted to say thank you for a really good product and just as important, great documentation.

    PS. it's also great to see that you are still updating it and adding more features
     
  5. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    Glad you got it working without many issues. If you do encounter any, please consider joining the Discord server (link below).
    Also, I would be very grateful if you could find some time to leave a review on the Asset Store. Means a lot to the asset devs.
     
    NickM48 likes this.
  6. Yany

    Yany

    Joined:
    May 24, 2013
    Posts:
    96
    Hey There,

    Do you think this is something that can help WC3D's multi-raycast solution in terms of performance?
    https://unity.com/releases/editor/whats-new/2022.2.0
     
  7. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    Not really. And I would like to point out that the processing of results of the raycasting takes way more time than getting the results. I have a working prototype without Raycasting at all, so that it the next logical step.
     
    Yany likes this.
  8. ainkiwi

    ainkiwi

    Joined:
    Oct 6, 2019
    Posts:
    4
    I have encountered the following problem with your asset that I've bought: I want to create a 2.5 D game and I would like to freeze rotation on Y axis, because the path the car follows is a straight line(as seen in photo - https://imgur.com/a/gHbwvfI), I also want to freeze position on Z axis so it doesn't go off the road, to the left, or right. However, after driving for a short period of time it goes out from it's path : both POSITION on Z axis, and ROTATION on Y axis are changed.
    I have tried multiple attempts ( Freeze rotation and pozition from Rigidbody doesn't work, it does something, but not enough). Can you please provide the fix for this problem? I'm not using any other physics on my car, only your asset. Thank you !
     
  9. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    Hello,
    Rigidbody constraints are not perfect and they always have a bit of drift when forces are acting on the body.
    What I would suggest is simply resetting the rotation along the Y axis through code each or every few frames. That way if there is any deviation you simply set it back to 0. You can do the same for the position. That way the physics will still work fine but it will not go out from its path.
     
  10. ainkiwi

    ainkiwi

    Joined:
    Oct 6, 2019
    Posts:
    4
    I have tried this fix in LateUpdate, but then, the car feels very weird, it feels like it's lagging, the physics becomes rubbish after, especially on jumps when it stops it from rotating.....
     
  11. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    Physics should be done in FixedUpdate.
     
  12. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    The new ground detection for WC3D is up and running nice and smoothly. Besides the more precise detection it is also much faster and less problematic to setup. Small downside is that it requires Unity 2021 or newer. This will be a part of the upcoming NVP2 update.
     

    Attached Files:

  13. Odiobill

    Odiobill

    Joined:
    Jul 16, 2018
    Posts:
    10
    Hi @NWHCoding! I'm considering buying your asset for the motorcycle racing game I'm working on.
    I have a couple of questions, I tried to look in the documentation and googled it but didn't find the answers, probably because the Motorbike module is pretty new.

    Is there support also for riders out of the box, preferably with IK?
    Regarding the multiplayer module, will you support in the future also the new "official" Unity solution (formerly MLAPI)?

    Thanks a lot for your time!
     
  14. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    There is no support for IK and the motorcycle module at this point is pretty basic. I would check the demo and see if you like the behaviour.
    The new Unity multiplayer will be added soon.
     
  15. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    Beta for the major update is on the way and will be shipped as a package inside the asset.

    Apart from rewriting most of the WheelController3D and doing a complete cleanup of the NVP2 code, there also many improvements all around (more details pre-release).
    One major change is that NVP2 will now support both WheelCollider and WheelController3D.

    Here are also a few performance numbers. This is in-editor, profiler overhead on top, so the performance in builds will be much better:

    Data for 38 vehicles, 144 wheels
    • WheelController.FixedUpdate() = 0.65ms
    • VehicleController.FixedUpdate() = 0.43ms
    • VehicleController.Update() = 0.08ms
    • PhysicsFixedUpdate() = 1.14ms
    For more frequent updates about the changes, consider joining the Discord server (link in the signature below).
     
  16. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    A few more updates on the beta.


    WheelController3D got a complete rewrite and no longer uses raycasting:
    upload_2023-1-27_21-28-2.png


    VehicleSetupWizard now offers WheelCollider as a wheel to use:
    upload_2023-1-27_21-30-11.png


    Things have been simplified a lot all over the asset, without removing any features:
    upload_2023-1-27_21-28-40.png


    Demo scene got a refresh:
    upload_2023-1-27_21-29-27.png


    And much more. Check the nvp2-beta channel in the Discord (link in the signature) for more info and a beta demo build.

    Beta will ship in parallel to the v1.9.4 in a few days time, after I iron out a few more bugs.
     

    Attached Files:

  17. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    Also, this is now possible:

    upload_2023-1-27_21-47-1.png
     
  18. Yany

    Yany

    Joined:
    May 24, 2013
    Posts:
    96
    If I plan to make a new racing game based on this asset, which version would you recommend: the beta or the stable? I plan to release it no sooner than a year. I plan to make it physics-heavy, so much stuff will rely on the car physics.

    Edit: also I'm interested in your new solution for the wheelcontroller. Just for the sake of technical curiosity, could you give a little in-depth peek, please, how does it work if no raycasting used? Anything you feel interesting enough to mention is fine. :)
     
    Last edited: Jan 31, 2023
  19. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    They are both included in the NVP2 package so you can try one and the other. Beta will replace the stable in the nearer future, as soon as I am sure that there are no larger bugs. I would go for the beta, even with a few known bugs it has at the moment.

    As for the methods, just take a look at the source code. After all, it is all included in the asset :).
     
    Yany likes this.
  20. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    Beta 10.1b is getting released. Here are the changes:

    10.1b
    31/01/2023
    • Fixed duplicate asset menu entries.
    • Moved VehicleSetupWizard to a separate assembly to be able to dereference WC3D inside VehiclePhysics2 assembly.
    • EngineRunningComponent basePitch was removed and the pitch now starts from 0 @ 0 RPM.
    • Fixed EV engine not spinning down to 0 RPM.
    • [WC3D] Improvements to the low speed behaviour.
    • Fixed surface detection when multiple objects hit.
    • “Force100HzPhysicsUpdate” has been removed and an info message added instead.
    • Improvements to the vehicle behaviour when using 50Hz physics update (dt = 0.02).
    • Fixed wheel getting stuck in air in compressed state while using native collider. Not properly tested since I could not repro.
    • Added friction coefficients to the IWheelUAPI, added IsVisualOnly instead of SetMultiplayerIsRemote().
    • ARB now works only when both wheels are on the ground.
    • FlipOverModule rewrite to use coroutines.

    10.0b
    30/01/2023
    • [WC3D] Major rewrite of WheelController. API breaking changes!
    • [WC3D] New ground detection method. Raycasting is no longer used and layer setup no longer required.
    • [WC3D] Changed the suspension bottoming out mechanism. This solves the issue with vehicles bouncing back after a fall.
    • [WC3D] Cleaned up the API and removed redundant properties. Implemented IWheelUAPI to avoid switching between WheelController and WheelCollider seamlessly.
    • [WC3D] Solved low speed friction creep.
    • [WC3D] Major performance improvements.
    • [WC3D] New inspector layout with tabs to reduce inspector height.
    • Code restructuring and cleanup.
    • Simplified settings tab. Physical properties moved to VariableCenterOfMass script (optional).
    • Removed NRigidbody and sub-stepping. It is now recommended to use Time.fixedDeltaTime of 0.01 instead of the sub-stepping that was provided by NRigidbody.
    • WheelComponent now accepts IWheelUAPI instead of WheelController, meaning custom wheel implementations are supported, as well as the WheelCollider through the provided WheelColliderUAPI script.
    • CharacterVehicleChanger and VehicleChanger have been integrated into a single script.
    • CharacterVehicleChanger now has an option to start in vehicle, which is now the default for the demo.
    • Modules are now drawn inside their respective wrappers instead of the VehicleController.
    • Cleaned up SoundManager and EffectsManager, as well as SoundComponents.
    • Removed ShowInTelemetry and ShowInSettings attributes. These used reflection and were never intended for production use.
    • Fixed snap oversteer issues under braking.
    • Fixed transmission rev matching issues.
    • (Re)Added welcome message popup on asset import.
    • Minimized property serialization to improve inspector performance and reduce serialization overhead.
    • Added scale warnings to VehicleController and WheelController due to large number of related support requests.
    • Fixed Blinker and Horn SetDefaults assigning wrong clips.
    • VehicleModule and VehicleComponent are now using the same NUI drawer.
    • Removed deadzone settings from Input tab. Deadzone should be set through the InputSystem/InputManager/Rewired/etc. Same with input inversion.
    • Removed freeze options from the VehicleController since they are no longer needed due to WC3D changes.
    • Improvements to the demo scene.
    • Multiple other smaller fixes and improvements.
     
  21. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    10.1b is available for download now.
     
  22. Yany

    Yany

    Joined:
    May 24, 2013
    Posts:
    96
    Wow nice improvements... and quick! Good to see this nice work you do.

    Something else:

    Would you ever consider adding a sound simulator, like this to your package at some point? That would be insane! :)

     
  23. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    There are two things, that thing is quite hard to develop and all the procedural approaches take quite a lot of CPU. I did some testing a few years ago with procedurally generated sound (a different approach to the above tho) and it is really hard to get it right and performant.

    What will be coming to NVP2 is the FMOD support as soon as I am done with the beta. Most likely as a paid module.
    However, it takes quite a lot of time to collect all the sounds, do the layering, etc. so I do not have an ETA. The development progress for it is at about 50%.
     
    Yany likes this.
  24. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    10.2b is on the way. Expect it in about 1 hour.

    Changes:

    10.2b
    01/02/2023
    • Bug fixes and optimizations on the VariableCenterOfMass script.
    • Fixed unstable idle.
    • ARB was removed in favor of the force application point distance setting on the WheelController.
    • Improvements the clutch. PID controller was replaced with engagement and disengagment speed values.
    • Fixed crash audio source being positioned at a wrong location and crash using the wrong container.
    • Fixed reverse beep never stopping playing.
    • Toe and caster are now only applied only on vehicle initialization or when toe or caster are changed (through scripting).
    • Improvements to the interaction between engine and transmission, eliminating the surge when starting from standstill.
    • Made NUI header state settings appear only when a single vehicle is selected.
    • Removed biasAB from limited slip differential as it makes no sense.
    • Fixed missing package dependencies.
     
  25. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    10.3b

    02/02/2023
    • Fixed jitter issues when switching to native friction.
    • Removed colliderOversizing.
    • Fixed skidmarks sometimes not being drawn.
    • Parted out VehicleController into a partial class with LOD and Multiplayer code in separate files.
    • VehicleComponent state checks are now event-driven.
    • Added tooltips for new fields.
     
  26. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    TyreWear script has been added. It works both with WheelController and WheelColliderUAPI:

    upload_2023-2-2_19-18-0.png
     
  27. hossei93

    hossei93

    Joined:
    Oct 12, 2021
    Posts:
    2
    Is it possible to disable the car vibration?
    Especially when the driver is inside the car and the car is not moving.
    I changed the engine type from ICE to Electric and still the car vibrates.
     
  28. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    Which version is this. There is no vibration, but the beta had a jitter issue in 10.2b (fixed for 10.3b) and the stable can get jitter if the friction is too stiff or Rigidbody inertia is set too low.
     
  29. hossei93

    hossei93

    Joined:
    Oct 12, 2021
    Posts:
    2
    I'm using 9.4f
    I mean, when the driver gets in the car and starts the engine and the car is not moving, there is a small vibration to show that the car engine is on.
    It is more noticeable when using a VR headset.
    Everything works fine as expected, I just wanted to disable this small vibration since it's a little bit annoying in VR.
     
  30. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    Exactly, there is no in-built vibration of any kind. You can test this by setting Project Settings > Time > Fixed Delta Time to 0.01. The vibration will most likely go away. The fact that it is there is most likely caused by an issue somewhere in the setup:
    • Inertia of the Rigidbody too low.
    • Try lowering the center of mass by a little bit.
    • Too stiff friction (for the fixed update rate).
    • Vehicle scale is off (i.e. not 1,1,1)
    Usually something of the listed above.
     
  31. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    A relatively frequently requested feature request has finally been implemented, will be available in a few days as a part of the beta:
    upload_2023-2-4_17-57-12.png
     
    Yany likes this.
  32. Yany

    Yany

    Joined:
    May 24, 2013
    Posts:
    96
    The voting seems to be very decided. :D
    Actually, It's not completely clear to me, what fmod can bring to this great asset. Will it be easier to configure? Will it sound better? Is it more performant? What's the value of that? (sorry if it's obvious to the community and it's just me being a rookie :) )
     
    Last edited: Feb 5, 2023
  33. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    FMOD support would bring:
    • Layered engine sound and moving of the sound logic to the FMOD, to some extent.
    • Improved sound overall.
    • Faster performance.
    • Easier to tune the sound since the logic is in good part inside FMOD.
    A lot of larger games use either FMOD of Wwyse for this reason.

    As for the softbody wheels, there will be some limitations as things go:
    • No native collsion as Unity as custom physics engine is used.
    • Windows/MaxOS/Linux only. Not suitable for mobile.
    • Will be porting the softbody code to C++ most likely, for performance reasons.
    • Mostly for use with a single vehicle, do not expect 10 AI cars to run softbody wheels.
    And due to the amount of development it will be a paid asset.

    I might still go with the FMOD module first as I already have it mostly finished (logic-wise, needs better sounds and some engine work), and the softbody wheel will need a lot of work still (at least two months).
     
  34. khos

    khos

    Joined:
    May 10, 2016
    Posts:
    1,487
    Hi, does this asset, or would this support softbody type wheels, or even if faked? Just curious.
     
  35. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    Hello, check the answer in the Discord.
     
  36. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    The beta is getting closer to replacing the current version with each update, most likely in ~1 week.
    Here is the latest (beta) update:

    10.4b

    05/02/2023
    • Added exhaust pop sound.
    • Added brake noise / sound.
    • [WC3D] Improvements to the ground detection.
    • Added TyreWear script. Works both with WheelController and WheelCollider (or anything that implements IWheelUAPI).
    • Fixed wheel clipping into the ground on the first frame.
    • Added option to choose between MeshCollider and SphereCollider for ground detection.
    • Fixed skidmarks being drawn with an offset.
    • The FixedDeltaTime message now only appears once per Editor restart.
    • Fix state settings adjusted through the VehicleController inspector not saved on restart.
    • Code restructure and cleanup.
    • Moved surface type detection to a coroutine.
     
  37. riba78

    riba78

    Joined:
    Feb 16, 2018
    Posts:
    33
    as softbody wheels you mean something like sims like rF2 o LFS are doing as visual deformation of the tyre when strechted by lateral/longitudinal forces applied or a full softbody simulation ?
     
  38. creat327

    creat327

    Joined:
    Mar 19, 2009
    Posts:
    1,756
    Have you tested the new without raycast performance on mobile?

    Also, some of us develop for multiplayer. The raycast solution was bad for that purpose since Photon Fusion would fail. Without raycast it can probably work now, have you tested any multiplayer samples?
     
  39. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    No, I mean the truss-based wheels that were featured in this thread a page or two ago. More with the intent on rock-crawling and slower speed games where the tyre deforming is important to the gameplay. So full softbody.
     
  40. riba78

    riba78

    Joined:
    Feb 16, 2018
    Posts:
    33
    Clear and I think it's great and it opens a wide range of uses.
    Really nice
     
  41. khos

    khos

    Joined:
    May 10, 2016
    Posts:
    1,487
    Any technique is fine.
    Also, I don't understand why I should visit a discord just to try find the answer myself, could the dev just say here?
     
  42. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    Not sure if you replied to the correct message, but I was not talking about the Discord.
    You can find a few videos/gifs towards the second half of the forum page here: NWH Vehicle Physics 2 | Page 11 - Unity Forum
     
    khos likes this.
  43. khos

    khos

    Joined:
    May 10, 2016
    Posts:
    1,487
    Ah ok, many thanks, that does look nice, any ideas on when something like that might become available, could be a very good addition to this already good asset! :)
     
  44. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    Working on beta still, the work will start after that.
    Most importantly, beta implements IWheelUAPI which allows usage of different wheel solutions with NVP2 which was not possible until now.
     
    khos likes this.
  45. creat327

    creat327

    Joined:
    Mar 19, 2009
    Posts:
    1,756
    @NWHCoding i think you missed my question here
     
  46. Yany

    Yany

    Joined:
    May 24, 2013
    Posts:
    96
    If I plan to use "replay" as ghost cars in my game, does NVP2 provide any high-level API/feature to simulate a controlled vehicle, or do I need to put something together in my way? In other words, is there something like a "Save movement" and "Load/Replay movement" method/API for the cars?

    If it's not something on the list already, this would be a very wanted feature on my part.
     
  47. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    You could use the GetMultiplayerState() and SetMutliplayerState() to save the vehicle state, together with position/rotation, and the set the vehicle to MultiplayerIsRemote = true to replay as if it were a client on the network. That is just one idea.
     
    Yany likes this.
  48. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    10.5b is being uploaded right now. A few smaller issues are still present, but these are either related to sound/effects or the wheel. The fixes from 10.4b are significant enough (especially in regards to ground detection) that I decided to publish it a bit early.

    10.5b

    07/02/2023
    • Added power, torque and RPM readings for each powertrain component inspector.
    • Fixed skid sounds not working.
    • Further improvements to the clutch. Eliminated stalling issues and added engagement RPM range.
    • Removed redundant IWheelUAPI functions and renamed it to WheelUAPI since it was turned into an abstract class instead (to allow for serialization in inspector).
    • Updated motorcycle to work with the beta.
    • Fix state settings adjusted through the VehicleController inspector not saved on restart.
    • [WC3D] Fixed most issues with MeshCollider-based ground detection. Option for SphereCollider was removed.
    • Multiple other smaller fixes and improvements.
     
  49. khos

    khos

    Joined:
    May 10, 2016
    Posts:
    1,487
    If this makes into the asset, it will be a buy from me :)
     
  50. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    It is in the asset right now. The beta is shipped as a separate package within the asset. Hence the two versions under the version field: 9.4f (10.5b).
    A few more things to solve and it will definitely replace the 9.4f as the main version quite soon.

    Here is the link to the latest beta build if you want to try it out: https://drive.google.com/file/d/1UIsqGHU2QCv846JfSbdxFvlgVZpUtjBO/view?usp=share_link