Search Unity

Assets NWH Vehicle Physics

Discussion in 'Works In Progress - Archive' started by NWHCoding, Nov 30, 2017.

?

Which networking solution do you want to see implemented?

Poll closed Jan 20, 2019.
  1. UNet - Unity Networking, getting deprecated sometime in the future

    1 vote(s)
    4.8%
  2. Mirror - Community replacement for UNet (https://github.com/vis2k/Mirror)

    6 vote(s)
    28.6%
  3. Photon

    12 vote(s)
    57.1%
  4. None - I will be implementing my own solution

    2 vote(s)
    9.5%
  1. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,325
    That would be drag. You can either use Settings > Drag (on VehicleController) or add Aerodynamics module and enable drag there. Effect will be quite similar - the only difference is that the aerodynamic drag takes size of the vehicle into account.
     
  2. MikeUpchat

    MikeUpchat

    Joined:
    Sep 24, 2010
    Posts:
    1,031
    Or change the final gear ratio.
     
  3. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,325
    Actually, if the power curve is sufficiently flat this will not make much difference. It will just force the engine to work at lower RPM where it has less power BUT if there is not enough drag this will actually result in higher top speed. But you can try it and see if you like the results.
     
  4. SufferinPup

    SufferinPup

    Joined:
    Jul 7, 2012
    Posts:
    23
    Thank you, this worked pretty well. A value of 0.25 seems to do the trick of limiting top speed without affecting acceleration too much (it still does affect it sadly, I wish there was a more simple independent "top speed" setting).

    A related question, turning the front wheels greatly reduces acceleration speed. This is realistic, but the amount it reduces it is huge. Is there any way to reduce how much it affects it? I have to set the power of my vehicle way higher than it should be just so you can hold W+D at the same time and start moving at all.
     
  5. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,325
    The drag is calculated the conventional way for aerodynamics which means that it increases with square of velocity, but that means that there will be some even at lower speeds.
    As for turning - I would try with an open differential. If you have locking diff or stiff LSD it could cause friction. With open differential there should be very little power lost. Aerodynamics should not have much if anything to do with this.
     
  6. SufferinPup

    SufferinPup

    Joined:
    Jul 7, 2012
    Posts:
    23
    Thanks, I tried switching to an open differential and I didn't notice any difference. It feels like it is very difficult to accelerate with the wheels turned, which is troublesome if you are trying to leave a parking space. Even with max throttle it just crawls out. This is a very heavy rear wheel drive vehicle with fairly low power (it is a 1940's troop transport from world war 2).
     
  7. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,325
    Does it have more than two axles?
     
  8. SufferinPup

    SufferinPup

    Joined:
    Jul 7, 2012
    Posts:
    23
    Nope, just two. I've attached a shot, it is a fairly standard vehicle.

    Capture.PNG
     
  9. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,325
    Hmm, could have to do with Ackerman steering. It should be calculated automatically. Could you please switch inspector to debug mode and check the value of wheelbase on the VehicleController?
     
  10. SufferinPup

    SufferinPup

    Joined:
    Jul 7, 2012
    Posts:
    23
    Strange I don't see that variable, we are using an older version (I think 1.1) so it is possible it was added later. I've been leery of updating the plugin, since we have a lot of vehicles working well (except for this one issue!).
     
  11. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,325
    Sure. In that case try to manually adjust Ackerman steering under Powertrain > Wheel Groups. In v1.1 it was set manually and if it is set wrong it might very well be that the front wheels are pointing slightly off when under steering and therefore causing friction. More about this here: https://en.wikipedia.org/wiki/Ackermann_steering_geometry

    In case you ever do try to upgrade here are the upgrade notes: http://nwhvehiclephysics.com/doku.php/UpgradeNotes
    And of course you can always try the upgrade on a copy first :) Besides, you can run through the changelog on the page above and see if you need any of the updates.
     
  12. SufferinPup

    SufferinPup

    Joined:
    Jul 7, 2012
    Posts:
    23
    Thanks for that, I've tried a few values and it does help a bit. I think the real solution here is to block out some time to upgrade the plugin. :) Thank you for all the help, this truck drives much better now!
     
  13. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,325
    That is one very unusual issue there. Which version are you using? (There were some major changes in previous versions). Also, does this happen with demo vehicles and are there any steps to reproduce? I.e. how do you handle respawning? It could very well be a bug so I would like to replicate if possible. If it is not too much of a bother you could send a repro project to my email (check signature).
     
  14. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,325
    Well, that is probably one of the issues there. Does the problem go away if you reduce power to more normal values (e.g. 360)? Also, try increasing the inertia of the engine and see if it gets better. My guess is that with that crazy power (3600kW = 4830hp) the solver goes through the roof and tries to apply NaN force or similar. Granted, it should not happen and it is for sure a bug. Do you get any errors?
     
  15. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,325
    Thanks for the info. I will try to reproduce. So just respawning the monster truck and running it into a wall produces this? It most likely has to do something with the new sub-stepping system where my version of physics does not actually handle collisions so when it syncs with the Rigidbody at the beginning of the next frame the positions might have significant position/rotation delta.
     
  16. MikeUpchat

    MikeUpchat

    Joined:
    Sep 24, 2010
    Posts:
    1,031
    How do I stop the steering from being reduced with speed in the demos, as soon as the car goes at any speed the steering reduces to virtually nothing.
     
  17. shanzebali

    shanzebali

    Joined:
    Aug 18, 2015
    Posts:
    4

    What is your best guess to stop vehicle from flying because i am trying for a while but its not getting me anywhere. I hope you can tell me if switching on/off of any module might help stop car from flying?
     
  18. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,325
    Check the steering settings, there is a speed sensitive steering curve mainly used to make it easier for keyboard users to control the vehicles at speed.
     
  19. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,325
    NWH Vehicle Physics 1 (this thread) does not have modules. Are you sure we are not talking about NVP2? (https://forum.unity.com/threads/nwh-vehicle-physics-2.863188/)

    If it is NVP2 have you used the VehicleSetupWizard or did a manual setup?
    If the vehicle just flies into the air after pressing the play button it is 99% due to ignore layers setup on WheelControllers and the wheels are detecting the vehicle itself as ground. Make sure to check this: http://nwhvehiclephysics.com/doku.php/Setup/WheelController
     
  20. MikeUpchat

    MikeUpchat

    Joined:
    Sep 24, 2010
    Posts:
    1,031
    I see no curve option in the demos, I don't yet own your asset, I still waiting for it do be able to do doughnuts etc. and the lack of being able to steer in the demo doesn't help.
     
  21. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,325
    The options in the demo scene are just a few basic options. The full list of components and their inspectors can be see on the Wiki of the asset: http://nwhvehiclephysics.com/doku.php/index
     
  22. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,325
    Thanks for the bug report. This is most definitely a bug and I will be investigating it today. Get back to you when I find the issue.

    Edit: Could you please PM me how exactly you are respawning the vehicle?
     
    Last edited: Nov 3, 2020
  23. MikeUpchat

    MikeUpchat

    Joined:
    Sep 24, 2010
    Posts:
    1,031
    Thanks, but I would like to be able to drive the demo without the annoying steering limit, will there be another demo which has that off so I control the steering instead of the asset?
     
  24. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,325
    It was originally introduced because there were complaints of steering on keyboard being too sensitive, so I dumbed it down so to say. Of course it can be turned on in the settings but your idea of adding it to demo has been added to TODO for the next demo since it is a good idea.
     
  25. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,325
    I have investigated this and have tried to move the vehicle to the start position as well as instantiate it at runtime and both tests ran fine. Is there anything specific you are doing? Also, what version are you using?
     
  26. DeathRace26

    DeathRace26

    Joined:
    May 26, 2019
    Posts:
    75
    What is the point of Substepping when you can use fixed timestep?
     
  27. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,325
    Because you do not want to run everything at very high update rates. Running physics in the whole scene at 200Hz or more would bog the performance down so what is done here is that the parts of physics (and the rest of the scene) run at 50Hz while the friction and powertrain run at higher refresh rate. And the end result is that with a lot of tweaking the performance stayed the same as before but the vehicle behavior was greatly improved. Besides, Nvidia PhysX does not same: https://docs.unity3d.com/ScriptReference/WheelCollider.ConfigureVehicleSubsteps.html

    One very obvious problem with low physics update rates and slip-based friction is that you get creep and also rubber-banding since friction has to wait for one frame to get the slip value and react.

    Also, it is running in FixedUpdate() - it is just that some parts run multiple times and the NRigidbody actually runs in front of the PhysX meaning that I know where the Rigidbody will be next frame before PhysX does.
     
  28. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,325
    Could you email me a repro scene? I have spent some time trying to reproduce this but had not luck.
    Or at least the section of code that is used for respawning.
     
  29. lukejaparidze

    lukejaparidze

    Joined:
    Dec 8, 2012
    Posts:
    11
    I'm having the same issue as mentioned above, occasionally, when colliding with something, the car will start spinning endlessly, if I force the max angular velocity to zero the car just starts flying straight up into the air. Any fix for this?
     
  30. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,325
    Could you please PM me a short video of the issue? Or even better a scene where I can reproduce this or at least steps. E.g. drive the demo car into a box at this and that speed. Also, does it happen with demo vehicles?
     
  31. SufferinPup

    SufferinPup

    Joined:
    Jul 7, 2012
    Posts:
    23
    Sorry if I'm missing something obvious, but how do I modify the velocityMagnitudeEffect in the CrashComponent? I'm searching all over the vehicle's settings but not seeing it. Thanks!
     
  32. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,325
    All the adjustable values for damage are under Damage Handler: Damage [NWH Vehicle Physics 2 Documentation]
    Anything specific you are trying to achieve?
     
  33. SufferinPup

    SufferinPup

    Joined:
    Jul 7, 2012
    Posts:
    23
    I'd like the crash sound to be louder, and it looks like modifying velocityMagnitudeEffect is the way to do that, but I don't see that available for editing anywhere. I obviously could just hack the code, but I was wondering if that was exposed somewhere.
     
  34. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,325
    Have you tried just adjusting the volume of the crash sound under Sound tab?
     
  35. SufferinPup

    SufferinPup

    Joined:
    Jul 7, 2012
    Posts:
    23
    Yeah, it defaults to 0.9 so changing it to the max (1.0) doesn't make it that much louder.
     
  36. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,325
    I would suggest just going to the script for the crash sound and changing the range. Volume can be >1, it is just that I limited the slider assuming nobody would need more. You can also usually enter the value manually next to the slider or in inspector debug mode.
     
  37. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,325
    From now on owners of NWH Vehicle Physics 1 or 2 can also get the WheelController3D asset for free from the Unity Asset Store.
     
  38. MikeUpchat

    MikeUpchat

    Joined:
    Sep 24, 2010
    Posts:
    1,031
    Have the demos been updated to remove the steering limit at speed, and also adjusted so can do doughnuts, which still seems very odd that such a good physics system doesn't just work for wheel spin.
     
  39. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,325
    Steering limit at speed feature is there because a lot of people use keyboards - I mentioned that earlier. I did loosen it up a bit tho. I have tweaked it to be a bit easier to do doughnuts without much throttle control needed but it is probably not exactly what you are after.
     
  40. MikeUpchat

    MikeUpchat

    Joined:
    Sep 24, 2010
    Posts:
    1,031
    Are these changes in the demos on your website as I just re downloaded and it seemed the same.
     
  41. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,325
    Yes, the changes are in the demo and have been since the release of v1.5. I will to a check of the code as it seems that around 0 m/s the friction stiffens which could be causing the doughnut issue.
     
  42. wjsehwls

    wjsehwls

    Joined:
    Dec 18, 2020
    Posts:
    3
    i want to implement a parking mode in your NWH.
    i asking you how to set the parking mode
    thank you
     
  43. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,325
    Are we talking about parking brake? In that case all the settings for that are under Control > Brakes tab of VehicleController and you can set it to 'hold to activate' or latching type where you press once to activate and then again to deactivate. Hopefully I understood the question correctly.
     
  44. wjsehwls

    wjsehwls

    Joined:
    Dec 18, 2020
    Posts:
    3
    My question means P mode on the transmission.

    Please explain in detail if there is a way to set it up.
    Thank you.
     
  45. wjsehwls

    wjsehwls

    Joined:
    Dec 18, 2020
    Posts:
    3
    I want to implement P (parking) mode on the transmission.
    thank you
     
  46. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,325
    Hello, were you the same person as the user on Discord that asked the same question at about the same time? In that case did you manage to get it to work using the parking brake as mentioned?
     
unityunity