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

    MK1_Dev

    Joined:
    Sep 7, 2018
    Posts:
    104
    Excellent! Thank you.
     
  2. isNewBird

    isNewBird

    Joined:
    Mar 27, 2019
    Posts:
    20
    Hello, why is my car still shaking after it has come to a complete stop?The car in your demo scene is the same thing.Is there any way to get him to rest completely, not sleep.thank you
     
  3. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    First check that you have v1.3.x installed as there were some changes to the static friction which solved the issue. Unity 2019.3 or newer is required.
     
  4. giraffe1

    giraffe1

    Joined:
    Nov 1, 2014
    Posts:
    302


    How come the back tires bends/tilts in/outwards sometimes? You can see at 1:10 mark. And other lots of other times in the video. Not the up and down motion.

    *** edit *** never mind. It appears like tires do behave like that when 4x4ing.
     
    Last edited: Sep 22, 2020
  5. michealcaj

    michealcaj

    Joined:
    Aug 18, 2017
    Posts:
    191
    Wow , lovely asset NWH
     
  6. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    Most military and offroad trucks have wheels that pivot around the differential so the camber varies a lot from the extended to the compressed suspension position. I would suggest checking any military or similar 6x6, 8x8, etc. truck.
     
    michealcaj likes this.
  7. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    Thanks. If everything goes to plan v1.4 is going to be even better as I am implementing sub-stepping into the physics engine. So far so good.
     
    Mixa1985 and michealcaj like this.
  8. michealcaj

    michealcaj

    Joined:
    Aug 18, 2017
    Posts:
    191
    Can't wait
     
  9. MikeUpchat

    MikeUpchat

    Joined:
    Sep 24, 2010
    Posts:
    1,056
    What is the recommended physics time step to use?
     
  10. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    Depends on your platform. If you can afford it 0.01 is great for desktop and will give you much better quality than then default 0.02. Still, sometimes (mobile, many vehicles) this is not possible so stick with the lowest you can use but avoid anything above 0.02. 0.016667 (60Hz) is a good compromise.
     
    Willbkool_FPCS likes this.
  11. giraffe1

    giraffe1

    Joined:
    Nov 1, 2014
    Posts:
    302
    I tried the default pc demo and tried the long truck with lots of tires and hooked up the trailer but when you reverse with the trailer it doesn't move at all. I mean like you cannot reverse the trailer. The trailer seems to act like a brake when reversing.

    Question:

    Does the weight of the trailer affect the vehicle pulling it?
     
    michealcaj likes this.
  12. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    Thank you for reporting this. More than likely the trailer has "Brake On Reverse" or similar option enabled.
    Yes, the weight of the trailer affects the vehicle pulling it since the two are connected by a physics joint so the weight of the trailer is effectively "added" to the pulling vehicle. NVP2 is fully physics based and everything is done through Rigidbody forces so if it affects PhysX (or whichever physics backend you are using), it affects NVP2.
     
  13. isNewBird

    isNewBird

    Joined:
    Mar 27, 2019
    Posts:
    20
    Hello!

    My car skates very easily, I've adjusted the SlipCoefficient for every wheel, and it's not the SlipCoefficient I want.Could you please tell me what else can control the vehicle sideslip?Thank you very much
     
  14. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    Working right now on an update that will solve the slip issues with physics substepping. The lateral slip currently has a small bug that can use wrong slip calculation that is intended for static slip for low speed slip instead. I will have a working tech demo for the new update in about a day or two at max.
     
    dsilverthorn likes this.
  15. isNewBird

    isNewBird

    Joined:
    Mar 27, 2019
    Posts:
    20
    hello

    Thank you very much for your help.

    But, the speed is lost very quickly.Why is that?
     
  16. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    WheelController has a 'drag' field. Apart from that there are engine losses that might be on the higher side. Will give this one a look. Is the speed lost quickly when the clutch is engaged or when rolling with clutch disengaged?
     
  17. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    Small dev update:
    Physics sub-stepping is working and nearly release ready in NVP2. Needs a bit more testing as the multiplayer will need some love too due to the changes.
    WheelController has also received some work over the past few days with overall improvements both internally and externally. I will be posting a changelog as soon as I am done with the testing.

    Edit: Here is a link to the WheelController demo with sub-stepping implemented. This is very close to the release version: https://drive.google.com/file/d/1B4dXRai8vvBV-6bZnDS3ZcVgD-Ked537/view?usp=sharing
     
    Last edited: Oct 2, 2020
  18. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
  19. MikeUpchat

    MikeUpchat

    Joined:
    Sep 24, 2010
    Posts:
    1,056
    Is the Lada meant to topple over its nose when braking, something seems very off for a car to do that? Is there any way to turn of the reduction in steering at speed or reduce it?
     
  20. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    If you can please wait a few days for 1.4 update which changes and greatly improves on many things though implementing physics sub-stepping. Latest demo is here: https://drive.google.com/file/d/1dm67btT6r6Is0vVOp_De2jq4tfITd8kH/view?usp=sharing
    Also, the Lada in the current version does have a combination of too stiff longitudinal friction and high center of mass. Please try the demo above (Win64) and see if you like the updated behavior better. Feedback is always welcome.
     
  21. MikeUpchat

    MikeUpchat

    Joined:
    Sep 24, 2010
    Posts:
    1,056
    You have done a great job on making this asset. I have tried the latest demo and it just doesn't feel right to me, the red car feels very unnatural on accelerating and braking, I cant really judge the handling as the steering is so limited at any kind of speed it just makes everything feel like its understeering. The red car also seems bounce about a lot, never seen a car do that in real life. And still impossible to do doughnuts.
     
  22. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    Bouncing is due to the mesh collider polys so you are going over the 'seams' all the time which makes it so. Need to up the resolution on the road mesh.
    As for the rest - that is why it is a test. The slip circle is getting some love today (in the test it was commented out hence no donuts and understeer). Also, some other areas need adjustment too but I wanted to put out a test built for people to try sub-stepping which is most apparent at lower speeds. Where before powertrain ran at ~10 updates for one FixedUpdate (and wheel update), now powertrain, wheels and the Rigidbody are all running at multiple updates per FixedUpdate and with no to little performance cost. This results in much tigher friction, esp. at lower speeds where the vehicles would always feel as they were drifting a bit.
    I will be posting a demo when all the things are finalized, this was more of a 'oh look it is working' build :).
     
    Last edited: Oct 5, 2020
    Rotary-Heart and Mixa1985 like this.
  23. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    Please try now. A few things were sorted out, including friction circle. Doughnuts are working now too.
    Handbrake is a bit too twitchy at high speeds for my liking so that is the next thing to investigate.
    NVP2 Test Build Download
    Edit: Just got rid of the understeer so a new build will be up in a few hours.
     
    Last edited: Oct 5, 2020
  24. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    Okay, the release candidate for v1.4 is up (same link as above).
     
  25. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    Beta for v1.4 is ready. If somebody wants to try it out send me a PM.
     
  26. SpookyCat

    SpookyCat

    Joined:
    Jan 25, 2010
    Posts:
    3,765
    Well done on a very impressive and comprehensive looking asset. If I didn't have my own system yours would be tempting :)
     
    Last edited: Oct 7, 2020
  27. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    Version 1.4 has been submitted for review and should be available in 1-2 days.

    Changes:
    * Implemented physics sub-stepping. Vehicles now run at higher update rate than the rest of physics. Despite this the performance is same to slightly better due to optimizations.
    * Revised friction and friction circle calculations. Eliminated excessive understeer.
    * Many small improvements and bug fixes to both VehicleController and WheelController.
    * Added adaptive smoothing to WheelController visual.
    * Added "Show Advanced Settings" option to WheelController. Only basic options are now displayed by default which reduces clutter.
    * Improved obstacle force calculation.
    * Improvements to WheelController.
    * Add latching handbrake option.
    * Added option to calculate load coefficient from custom curve or automatically (default).
    * Physical properties now can only be changed out of play mode or through scripting before the vehicle is initialized. This is a performance optimization.
    * Reworked and fixed air brake hiss sound.
    * Fixed TrailerHitchModule Attach On Play option not attaching the trailer.
    * Fixed Ackerman steering bug.
    * Fixed OnPointerUp not registering when multiple touches are present resulting in stuck inputs on mobile.
     
  28. SirSkylake

    SirSkylake

    Joined:
    Oct 19, 2016
    Posts:
    7
    Hi, in 1.4 update has a very slow acceleration. I have also tried in a fresh new project and the acceleration is very slow compared with previus versions.
     
  29. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    The previous behavior was unrealistic. If you have wheel spin you can improve acceleration by increasing longitudinal force coefficient on WheelController. The other two causes could be clutch that is too slow to engage or the obvious one: lack of power on the engine. Doubt that it is the last one.
     
  30. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    Version 1.4.1 is on the way with the following changes:
    * NRigidbody is now added to exisiting vehicles automatically if missing.
    * Fixed null event throwing errors in VehicleController.
    * Fixed "No Input Provider" warning even when 'Auto Set Input' is false.
    * Fixed wheels falling through ground when not added as output to powertrain component and the vehicle state is toggled during playtime.
    * Fixed high powered RWD vehicles pulling to one side when going straight.
    * Fixed TrailerHitchModule Attach On Play option not attaching the trailer (again).
     
  31. geralex

    geralex

    Joined:
    Apr 17, 2014
    Posts:
    7
    If I bought the first version, do I need to buy the second now?
    An update has been released - buy it? =)
     
  32. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    Hello,
    NVP1 and NVP2 are separate assets with not much in common so there is an upgrade price.
     
  33. Barritico

    Barritico

    Joined:
    Jun 9, 2017
    Posts:
    374

    You already responded to this several months ago.
    In any case, I said I HOPE OR WISH, not that it was done.

    Thanks for reiterating the answer.
     
  34. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    Ah, I knew it was familiar from somewhere. The Asset Store notifications decided to highlight the wrong post for some reason so I automatically replied without checking the date. My bad.
     
    Barritico and nobluff67 like this.
  35. joanpescador

    joanpescador

    Joined:
    Dec 21, 2016
    Posts:
    122
    Regarding Ashul's issues of NWH conflict with other packages, I'm wondering if you are aware of a conflict between NWH and Steamwork.net. My understanding is that NWH give error with Steamwork.net packahe for sharing "InputSystem" namespace.
    I'm willing to buy NWH but I would like to know if has been opportunity to detect / test / correct this issue.
    Obviously steamwork.net is a must for many projects and can't be surrounded.
    Some info about that?
    Thanks.

    https://steamworks.github.io/ -- Steamworks .NET C# Wrapper
     
  36. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    Actually - all scripts in NWH Vehicle Physics 2 are under NWH or NWH.[AssetName] namespace so highly unlikely that that is causing any issues. What could be happening is the fact that Unity for some reason does not check namespaces when importing scripts so it is prone to overwriting any existing scripts with the same name.

    InputSystem namespace is a namespace from Unity.InputSystem (their 'new' input solution that will replace InputManager in the future) so there should be no issues.

    Edit: Just tried importing Steamworks into NVP2 project and 0 issues. All I did was drag the Steamworks unitypackage as it says in the guide. IF Steamworks requires InputManager or InputSystem to be active you can do that by going to Project Settings > Player > Input and choosing Both. That is what I recommend in the docs anyway.
     
  37. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    v1.5 is on the way with the following changes:
    * Restructured the asset to prevent errors when trying to import multiple NWH assets in the same project.
    * Fixed terrain texture issue when the vehicle goes over the edge of a terrain.
    * Improvements to WheelController's damper. Some re-adjustment will be needed on existing vehicles. Damper now has separate bump and rebound curves.
    * Fixed major damper bug that rendered damper ineffective under high spring velocities.
    * Added warning for Powertrain > Wheels ordering.
    * Transmission now calls ReconstructGearList() automatically after the number of forward or reverse gears has changed or a different gearing profile has been assigned.
    * Renamed NWH.VehiclePhysics2.Input.Input to InputHandler to prevent confusion with UnityEngine.Input.
    * Added deadzone setting to InputManager and InputSystem VehicleInputProviders.
    * Fixed 'Brake On Reverse Direction' not working in some cases.
    * Fixed InputHandler.Vertical returning wrong value under braking.
    * Fixed GroundDetection querying terrain texture out of bounds.
    * TrailerHitchModule now searches for trailers across all loaded scenes.
    * Fix input sticking on scene reload when using SteeringWheelInputProvider.
     
    GLID3R82 and nobluff67 like this.
  38. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    NWH Vehicle Physics 2 is now on sale!
     
  39. arie1994

    arie1994

    Joined:
    Jun 30, 2016
    Posts:
    86
    just bought nwh2 installed on unity 2019.3 and cant run due to errors:

    Library\PackageCache\com.unity.inputsystem@1.0.0\InputSystem\Editor\Internal\EditorHelpers.cs(52,27): error CS0117: 'AssetDatabase' does not contain a definition for 'MakeEditable'

    Library\PackageCache\com.unity.timeline@1.2.14\Editor\State\WindowState.cs(718,21): error CS0103: The name 'PlayModeView' does not exist in the current context
     
  40. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    Hello, could you PM me the invoice so I can check which version it is exactly?
    This seems like an import issue on the Unity side as none of these two errors are caused by my asset directly.
     
  41. arie1994

    arie1994

    Joined:
    Jun 30, 2016
    Posts:
    86
    -The engine component checks for damage and stops working if too much damage has been taken. The transmission gets damage too but I don't see any way for it to effect the vehicle, unlike the engine that got checks for damage in the code. Am I missing something?
    - When changing vehicles all other vehicles go to "sleep", but I want to control them by AI script.
    how do i choose what vehicle get player input without forcing other vehicles to "Sleep"?
    - throttle goes from 0 to 1. how do i make the AI reverse?
     
    Last edited: Nov 28, 2020
  42. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    - No, not missing anything. The transmission does not have any damage effects.
    - Depends on your use case. You can either configure the vehicle changer to not put everything to sleep, you can manually put vehicles to sleep as need or you can use different state settings for the AI vehicles.
    - There is a "Vertical" axis that acts as a combined brake and throttle that was put in there for AI use. 1 for full throttle, -1 for brakes/reverse. So myVehicleController.input.Vertical.
     
  43. arie1994

    arie1994

    Joined:
    Jun 30, 2016
    Posts:
    86
    I still don't get how do I choose a vehicle to control and then how to stop "possessing" it.The vehicle changing scrip just deals with what sleeps and what awakes but can't find how to take control over a vehicle and then just stop at will
     
  44. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    From now on owners of NWH Vehicle Physics 1 or 2 can also get the WheelController3D asset for free from the Unity Asset Store.
     
    GLID3R82 and dsilverthorn like this.
  45. dsilverthorn

    dsilverthorn

    Joined:
    May 14, 2017
    Posts:
    839
    Awesome!
    Thank you!
     
  46. TokyoWarfareProject

    TokyoWarfareProject

    Joined:
    Jun 20, 2018
    Posts:
    814
    Hello I just aquired the asset, I've to say I tested the previous version demo and I saw some flaws in behaviour and did not aquire. I was at that moment using other physics system for prototyping and feeled better but new demo really feels very good and so I purchased. Congrats. I can´t wait to start messing around. In my view you know if a car physics is good in ther first corner XD.
     
  47. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    I am glad you like it more now. The difference is more than likely in the new friction model, physics sub-stepping and the fixed damper bug.
     
  48. mindravelinteractive

    mindravelinteractive

    Joined:
    Jun 26, 2018
    Posts:
    15
    Can you guide me how to do the following: I am creating a side scroller monster truck stunt game and only need the car to go straight - not slip or steer at all (even on jumps). I tried restricting the rigidbody rotations but the vehicle behaves weird. What will be the best way to achieve this?

    Thanks
     
  49. TokyoWarfareProject

    TokyoWarfareProject

    Joined:
    Jun 20, 2018
    Posts:
    814
    May be you could try add two invisible walls on each side and add a physics material of friction 0
     
  50. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    Actually, contraints might be a good way to go but since v1.4 and physics sub-stepping implementation constraints are buggy. This is because NRigidbody (the sub-stepping solution) does not support constraints but I have added this to the TODO list for the upcoming update.
    If you are making a 2D game or want a similar effect you might try to set the Y rotation of the vehicle to 0 and rigidbody.angularVelocity.y also to zero. If you do not want vehicle to be able to roll you would do that also for the Z axis (assuming you want your vehicle to travel along the X-Z plane).