Search Unity

  1. Get the latest news, tutorials and offers directly to your inbox with our newsletters. Sign up now.
    Dismiss Notice

NWH Vehicle Physics 2

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

  1. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,274
    The updates for NVP2, DWP2 and WC3D have been submitted and will fix the issues introduced in the previous upgrade. The requirement for .NET 4.x was removed and the issue with the missing 'using' directive in DWP2 has been fixed.
    This should make upgrading easier since the .NET error was causing the import to break mid-import.
     
    Mixa1985 likes this.
  2. TonismoGames

    TonismoGames

    Joined:
    Jun 12, 2018
    Posts:
    69
    @NWHCoding
    Hi, I am trying to get my vehicle to do wheelies by adding more power and grip. The physics isn't allowing it.
     
  3. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,274
    There are a few factors but one limit to how much grip you can get is the number of the physics substeps (Settings tab). Other than that there is also longitudinal force coefficient of the WheelController. Achieving wheelies is still not simple - most of the street legal cars can not do it. Also, you want to have high squat setting on the WheelController.
     
  4. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,274
    NWH Vehicle Physics 2 and Dynamic Water Physics 2 are currently 50% off as a part of Unity Spring Sale.
     
    Rowlan likes this.
  5. Slashbot64

    Slashbot64

    Joined:
    Jun 15, 2020
    Posts:
    43
    There is Mirror example scene?
    Motorbike support?
     
  6. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,274
    There is a Mirror, as well as PUN2, example scene.
    Motorbike support has not been added as I have been pushing NWH Aerodynamics.
     
  7. Slashbot64

    Slashbot64

    Joined:
    Jun 15, 2020
    Posts:
    43
    Will motorbike support come?
     
  8. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,274
    A rough sketch of it has been made and the bike works on the flat surfaces but I really can not give an ETA on this module as I really do not have one. NWH Aerodynamics is releasing soon and that will need my attention for some time so I will refrain from promising anything.
     
  9. Slashbot64

    Slashbot64

    Joined:
    Jun 15, 2020
    Posts:
    43
    Would it be easy-ish to use this system for a kart car setup given replacing the models/wheel and reconfiguring I assume it should be able to handle most 4wheels setups with ease, but looking at a more arcade kart car so maybe some values would need to be less physics based?
     
  10. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,274
    It is actually quite easy to get the more arcade tire friction values just by reducing the lateral slip coefficient and increasing the lateral force coefficient.
     
  11. Slashbot64

    Slashbot64

    Joined:
    Jun 15, 2020
    Posts:
    43
    Bought it, just wondering if there is some quick guides on how to.. like which settings to look at changing to achieve faster acceleration, more tire grip and less wheel spin etc?

    "reducing the lateral slip coefficient and increasing the lateral force coefficient" haven't seen that in the options yet.. can you point it out
     
  12. Slashbot64

    Slashbot64

    Joined:
    Jun 15, 2020
    Posts:
    43
    Also checked out the Mirror scene, worked better with the mirror Smoothsync addon, anyway I was wondering howcome there isn't tyre skidmarks for client cars synced aswel, could that be added as an option to sync or show in the mirror script?
     
  13. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,274
    These are all in the WheelController inspector, not the VehicleController inspector. I really need to add a small guide for friction but in general: lower slip coefficient means more headroom before you get wheel slip/spin and higher force coefficient means more grip.
    The force coefficient, both lateral (sideways) and longitudinal (forward), pretty much determines tire grip. The slip coefficient could be loosely interpreted as the sidewall stiffness. I would suggest playing with both values to get the feel for what they do.
     
    dsilverthorn likes this.
  14. Slashbot64

    Slashbot64

    Joined:
    Jun 15, 2020
    Posts:
    43
    And the settings needed to get a much faster acceleration? like from getting into the vehicle to moving forward most example vehicles all have a 'realistic' feel and I'm looking at a more arcade so what things are involved for that?

    I do think some quick guides on all the settings involved for achieving certain goals would be helpful... also the tire track marks in mirror not showing on client cars?
     
  15. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,274
    Lower longitudinal slip coefficient (e.g. 0.6) and higher force coefficient (e.g. 1.5) will increase the grip, same as for the lateral friction.

    Effects are not synchronized across the network and that is why skidmarks do not show.
     
  16. Slashbot64

    Slashbot64

    Joined:
    Jun 15, 2020
    Posts:
    43
    "Effects are not synchronized across the network and that is why skidmarks do not show." ..could they not be simulated based on the client inputs received for other movement input? as an option the mirror script anyway?
     
  17. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,274
    They could. It would increase the amount of data transferred over the network since the vehicle on the client is pretty much kinematic. It is not that it can not be implemented, it is just that it has not been implemented yet.
     
  18. Rujash

    Rujash

    Joined:
    Jan 3, 2014
    Posts:
    30
    Hello,

    The vehicle wizard makes wheels very small, will not detect 4 wheels - and will only drive in one direction.

    When I fix the wheels or duplicate wheel controllers to add to rear wheels, along with the size of the wheel, it still only lets me drive in one direction.

    I can fix everything except it driving in one direction (when I press forward or backward), how do I fix that?

     
    Last edited: Apr 26, 2021
  19. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,274
    Hello, could you send me the buggy model so I can see what is happening in there? Also, for some reason two of the wheels are not set up. For the wheel size I believe that it might have something to do with the model scale and I am not sure why it would not drive in reverse but it could be due to the failed differential setup. If you made some changes to the model even better option would be to send me the model + prefab so I can replicate the exact issue.
     
  20. Rujash

    Rujash

    Joined:
    Jan 3, 2014
    Posts:
    30
    I don't believe I can due to it being another person's asset. I e-mailed them requesting permission and will reply again if they grant permission. I would have to send it over DM or E-mail, likely.

    Is there a tutorial on setting up the differential?
     
  21. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,274
    Your Wheels tab shows only two wheels from what I can see which means that there is an issue somewhere. I asked for the model to check if it is an issue with the wizard (which I did test extensively but there is an infinite number of possible model configurations) or with the setup itself. From the video, everything looked fine and that is why I would like a look.

    You could however either add the rear wheels that for some reason did not get set up manually under the 'Wheels' tab and then assign these as the output to the differential under the 'Differentials' tab or remove the differential which has no output. A diff without output might cause an issue that you are having. I am just wondering why only the front wheels got set up.

    There are also the docs here for powertrain, including differentials: http://nwhvehiclephysics.com/doku.php/NWH/VehiclePhysics2/Powertrain/Powertrain
     
  22. Rujash

    Rujash

    Joined:
    Jan 3, 2014
    Posts:
    30
    I went ahead and sent it via conversation. The asset publisher allowed me to share it. I'll take a closer look at that stuff if it can't be resolved. Thanks.
     
  23. Alekxss

    Alekxss

    Joined:
    Mar 25, 2013
    Posts:
    165
    Hi! There is some bug with trailers, it can be easy reproduced in demo, and it still exist in last two versions.
    Just start drive with trailer forward + turn and stop.
    Now look on trailer closer - it will automatic slow turn itself. :confused: or move to side
    This not reproduced if set body substeps to 1
    This reproduces and in my own vehicle configs with another tractor vehicle (from different plugin)

    here is GIF
    https://i.gyazo.com/9bfe82a3f4cf79a931582aa0d51c78c0.gif
     
    Last edited: Apr 28, 2021
  24. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,274
    You are correct. It seems that the NRigidbody and joints are not playing that well together. Will see what I can do.
     
    Alekxss likes this.
  25. Rujash

    Rujash

    Joined:
    Jan 3, 2014
    Posts:
    30
    How is this fixed, when the car is barrel rolling for a long time, so the car has more gravity, more roll resistance? Even if it's going fast and it'd be "technically realistic", it doesn't look like a car can actually do that:



    I think the ability to 'dampen' or 'crunch' on impact would prevent the amount of rolling that takes place.
     
    Last edited: May 2, 2021
  26. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,274
    The rolling is purely PhysX collision and when high speed collisions happen these can be quite frantic even if the default value for the vehicle physics material is set to lowest bounce settings. One option would be to increase the drag and angular drag of the Rigidbody after the collision if the wheels are not on the ground. In real life cars absorb a lot of energy by crumpling but since that is not the case with the Rigidbody colliders that energy is all transferred into kinetic energy and things like this happen. Unfortunately I had no luck with modifying PhysX collision as the only thing that can be done is applying the forces after the fact which does not give the best of results.
     
  27. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,274
    Update v1.7 is ready. The focus was improving the behavior of the physics - especially over bumpy terrain. Here are the changes:
    • WheelController can now be used with 'Max Spring Length' of 0.
    • Improved wheel depenetration and added depenetration settings to WheelController.
    • Reworked FlipOverModule and added instant flip over.
    • Fixed ReorderableList crashing Unity when exiting play mode. Only Unity 2021.1.
    • Added support for NetworkRigidbody to MirrorMultiplayerVehicle. Collisions now work in multiplayer too. If NetworkRigidbody is not attached vehicle will be kinematic as before the update.
    • Fixed multiple issues with powertrain inertia.
    • Fixed WheelController not applying any force to surface when bottoming out and spring strength is 0.
    • Fixed WheelController spring gizmos being drawn in wrong place.
    • Fixed NaN issue when max spring length is set to 0.
    • Fixed VehicleComponent not having Enable() called when entering play mode resulting in some modules not initializing properly.
    • Fixed ApplyForceToOthers not applying correct friction force.
    • Fixed missing trees in the Racetrack demo scene.
    • Fixed transmission going into neutral after car stops moving while 'Require Shift Input' selected.
    • Added ''Apply Brakes When Speeding“ option to CruiseControlModule.
    • Added ability to apply throttle manually while cruise control is active.
    • EngineComponent.RPMPercent now returns RPM percentage in relation to rev limiter instead of the solver maximum RPM allowing it to actually reach 1.
    • Modified TransmissionComponent to allow gear skipping at full throttle.
    • Other minor bug fixes and improvements.
     
    Mixa1985 likes this.
  28. Davidbillmanoy

    Davidbillmanoy

    Joined:
    Jul 7, 2014
    Posts:
    103
    Hello. I really need help with the AI System for NWH 2. I already set up the waypoints in the sample track scene, and all I need to do is to make the AI control the AI Car. Anyone made an AI Controller Script for NWH 2?
     
  29. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,274
    AI is not included with NWH Vehicle Physics 2, but it has been designed with it in mind. That means that you can use most of the 3rd party AI assets with it since all you need to do to control the car is set the Vertical and Horizontal
    inputs of the vehicle (e.g.
    myVehicleController.input.Vertical = myValue;
    . The waypoints will be of course asset specific. I believe that there are also open source AI solutions that you could use, but I have not done much with either.
    Also, please check the Scripting section of the Input documentation: http://nwhvehiclephysics.com/doku.php/Setup/Input
    It is very important to set "Auto Settable" to false or the vehicle will overwrite your inputs.
     
  30. Rujash

    Rujash

    Joined:
    Jan 3, 2014
    Posts:
    30
    I am attempting to make a component which attaches to a vehicle and detects that each wheel isGrounded, so I can run a drag modifications on every rigidbody attached to it when they aren't grounded.

    Right now attempting to get every child object and see if there's a wheel component to the check if isGrounded is false or true for each one. I am going to be attempting also to modify the values of NWH's drag values first before involving Unity's.

    Is there an easier way? If not, any help you can give?

    I'd make this into a module but if I can't make it a component first I'd be hopeless at that.
     
  31. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,274
    If you want to use this approach you can just create a single script that checks if the vehicle is grounded by iterating through myVehicleController.Wheels and applying drag as needed. You can also use the collision event to trigger the drag increase if the wheels are not on the ground.
     
  32. isNewBird

    isNewBird

    Joined:
    Mar 27, 2019
    Posts:
    14
    Hello, I am trying to cancel the slight sway of the vehicle while it is still.Set Freeze While Idle to true.It still wobbles slightly.The same problem exists with the vehicles in the demo scenario.Is it possible to have a switch to cancel vehicle shaking directly?thank you
     
  33. isNewBird

    isNewBird

    Joined:
    Mar 27, 2019
    Posts:
    14
    I updated to the latest version after you modified the CVT.Very good.But I couldn't find a demo of the new CVT, and the parameters I set up got off to a very fast start.The revs were quickly filled up.Is there a way to increase it linearly?How should I set it?
     
  34. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,274
    Hello,
    if you have vehicle jitter make sure that you set the dimensions to the correct value (VehicleController > Settings) and click on Calculate Inertia after setting the dimensions. Also, make sure that the center of mass is about the middle of the vehicle, about where the handbrake would be on manual cars. The freeze option is just to prevent slip on slopes as this is downside of slip-based approaches to simulating vehicles and even the inbuilt WheelCollider has it.
     
  35. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,274
    This was a recent change. I just updated the online docs to match the current version as they were outdated.
    For CVT you should use one (not two like before) forward gear and one reverse gear. If the vehicle reaches the redline at too low speed reduce the forward gear number / ratio.
     
  36. isNewBird

    isNewBird

    Joined:
    Mar 27, 2019
    Posts:
    14
    Thank you very much for your answer.I'll have a try.
     
unityunity