Search Unity

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,350
    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:
    85
    @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,350
    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,350
    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:
    63
    There is Mirror example scene?
    Motorbike support?
     
  6. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,350
    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:
    63
    Will motorbike support come?
     
  8. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,350
    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:
    63
    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,350
    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:
    63
    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:
    63
    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,350
    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:
    63
    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,350
    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:
    63
    "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,350
    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:
    33
    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,350
    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:
    33
    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,350
    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:
    33
    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,350
    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:
    33
    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,350
    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,350
    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:
    106
    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,350
    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.
     
    Fibonaccov likes this.
  30. Rujash

    Rujash

    Joined:
    Jan 3, 2014
    Posts:
    33
    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,350
    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,350
    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,350
    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.
     
  37. w34edrtfg

    w34edrtfg

    Joined:
    Nov 23, 2014
    Posts:
    62
    I've tried the demo build and i couldn't move the camera inside the vehicle. Is that a bug? (I could move it on third person view)
    It looks really cool i had some fun jumping off the cliffs and checking the vehicle aftermatch xD
     
  38. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,350
    The camera movement in first person is an option but is not checked by default. The feature was implemented a few versions ago.
     
  39. w34edrtfg

    w34edrtfg

    Joined:
    Nov 23, 2014
    Posts:
    62
    Cool, ty for fast replying!
    Last(?) question:
    I don't have a proper collider for my vehicle so my workaround/hack was to use a MeshCollider with vehicle's body that is not a child and is moved on every update (so Unity doesn't cry saying that Rigidbodies don't support non-convex mesh colliders).
    Does this package have any workaround by itself or i will have to integrate my hack?
     
  40. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,350
    The asset uses Rigidbody so all the same rules apply. Easier way to achieve (and faster) what you want is by using a few box colliders to approximate the box shape. Way more performant. And of course you can use a convex mesh collider which works quite well for most vehicle shapes.
     
    w34edrtfg likes this.
  41. blinkyspoogle

    blinkyspoogle

    Joined:
    May 13, 2021
    Posts:
    2
    Hi - I was hoping you could help making wheel spin sounds and skid marks work on easyroads3d ? it seems like setting the correct terrain index number for asphalt in ground detection would be the answer, but i'm coming up short on actually solving this - thanks
     
  42. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,350
    Actually, the demo scene road was created using EasyRoads3D. What you need to do is assign a mesh collider to the road and use a 'Road' (default) tag. You can define other tags (one or multiple) to your surface. The terrain index number is just for the default Unity terrain.
     
  43. blinkyspoogle

    blinkyspoogle

    Joined:
    May 13, 2021
    Posts:
    2
    thanks so much for your help :) sorted
     
  44. creat327

    creat327

    Joined:
    Mar 19, 2009
    Posts:
    1,412
    I'm trying to make this work with a motorbike. Is there a way to achieve this?
     
  45. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,350
    It will work with motorcycle-like vehicle but there is no official support for them yet as the motorcycle will just fall over once the play mode is entered. I have been working for some time on the motorcycle module for the asset that includes motorcycle controls but I do not have ETA at this point.
     
    Aetherial87 likes this.
  46. yektasarioglu

    yektasarioglu

    Joined:
    Dec 29, 2018
    Posts:
    3
    Hi, I'm trying to import the unity asset into my project but I'm getting

    Asset import failed, "Assets/NWH Vehicle Physics 2/NWH/Common/Input/SceneInputActions.inputactions" > DirectoryNotFoundException: Could not find a part of the path "E:\" 


    error. Do you guys know how to solve this issue?
     
  47. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,350
    Make sure to use the latest version. The error you are describing has been fixed a few months ago and should not be happening any more. It was caused by the absolute path in the InputActions class generation path instead of relative (just leaving the field empty).
     
  48. royce1

    royce1

    Joined:
    Sep 30, 2017
    Posts:
    1
    Hi there, just wondering if you have any ideas in what's causing the problem I emailed you about? (With Pun2 multiplayer) where both instances are controlled (editor and standalone......or 2 x standalone), the demo slot car scene works as it should and I followed your set up instructions (twice) as I started a new project to be sure I hadn't missed anything. The NWH Pun2 demo scene has the same issue. I did upgrade the Pun2 to latest version last week if that has anything to do with the issue or have I missed something else?
     
  49. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,350
    Just replied to the email. Looking into it right now.
     
  50. schaefsky

    schaefsky

    Joined:
    Aug 11, 2013
    Posts:
    72
    Hello, I have the demo from 16th of April 2021. What irritates me is that the "red sportscar" will "steer" quite strongly to one side if you are going over a 100km/h and hit full brakes with ABS enabled. Does not happen if you disable ABS.
    Also I feel like both the sports car and the Lada spin out of control a bit too easily when applying breaks and steering.
    Can those things be fixed with vehicle setup or is it working as intended?

    FYI when walking and using an XBOX controller the axis for the right stick to look around are both flipped in the demo.
     
unityunity