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

    EnesZuuks

    Joined:
    Dec 1, 2022
    Posts:
    13
    Looks a little better. But after v11.17 update, there were noticeable changes in sound and performance in all the vehicles I set while developing the project. For example, the first link is the start of the vehicle of the old version, the second is the start of the vehicle of the new version.

    https://drive.google.com/file/d/1TG_8sr4YTWlB3UW_QXkXi0-UXygsMzpJ/view?usp=share_link
    https://drive.google.com/file/d/1lxwYtfPQOfJofu2ZM1aBagX9B_zzukyP/view?usp=share_link
     
  2. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    Well, I did spend some time improving the starter and the start sounds, so these are not accidental.
    I hope these are not causing issues for you?
    The older version had issues such as applying throttle while the starter is active, starting faster than the set time, starter sound not following the engine RPM, etc. and these were solved with the update.
    As for the performance, the default asphalt friction curve B parameter was dropped from 11.5 to 8, I explained the whole reasoning behind this on the Discord but in short: better handling, esp. when using keyboard.
    For the full list of changes check: Changelog [NWH Vehicle Physics 2 Documentation]
     
  3. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    NWH Vehicle Physics 2 and Dynamic Water Physics 2 are both 50% off currently as a part of the Unity Spring Sale!
     
    ironcladmerc likes this.
  4. ironcladmerc

    ironcladmerc

    Joined:
    Feb 13, 2017
    Posts:
    13
    I picked both up. the vehicle physics is quite frankly amazing and is even better than I thought it would be. The only thing now is to figure out how to fully use all the features.
     
    NWHCoding likes this.
  5. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    Glad you are liking them. Please consider leaving a review on the Asset Store page if you find some time.
    Otherwise, there is a Discord in the signature if you ever need any support - or if you just want to see what everyone is doing :).
     
  6. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    11.20f

    17/05/2023
    • [WheelGroup] Fixed solid axle camber, bug introduced a few versions ago.
    • [MotorcycleModule] Added 'useHitNormalAsUp' option where the motorcycle uses the current wheel hit normal instead of the world up to calculate the lean angle, making it work in loops, etc.
    • [TransmissionComponent] Fixed NaN caused by currentGearRatio being ~0, but not == 0.
    • [WheelUAPI] Added ForceApplicationPointDistance to the WheelUAPI.
     
    dsilverthorn likes this.
  7. dsilverthorn

    dsilverthorn

    Joined:
    May 14, 2017
    Posts:
    840
    I'm using an character controller that is not created until after runtime, and the character object name in the scene manager vanishes in runtime (changing to missing(game object)), but returns to player game object when returning to edit. (because it doesn't really exist during edit mode) How can I set it to recognize my character if that character is created at runtime?
    Can player tag or a fixed name be used somehow?
     
    Last edited: May 20, 2023
  8. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    Hello,
    you should be able to simply assign the character GameObject to the `Character Object` field of the VehicleChanger, assuming that you have ticked the `Character Based` option. Although there are a few questions, such as what happens when there is no character present - should a vehicle be active?
     
    dsilverthorn likes this.
  9. dsilverthorn

    dsilverthorn

    Joined:
    May 14, 2017
    Posts:
    840
    I have that set up and it works with a simple character. When I add the controller to the scene, which is "First Person Exploration Kit", it adds the character when you press play. All that is in the scene is core controls, and a start location prefab. At runtime a character is created. I've added the prefab of the character GameObject to the Character Object field, but when I press play the goes missing. My player is created and works, but I cannot enter a vehicle.
     
  10. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    It sounds like you are assigning the prefab to the field, and not the instantiated character GameObject. What you need to do is create a script that, when your character gets instantiated, sets the character field of the VehicleChanger. Possibly assign an empty "dummy" game object to the character field as a placeholder until your character is spawned if there is a delay.
     
    dsilverthorn likes this.
  11. dsilverthorn

    dsilverthorn

    Joined:
    May 14, 2017
    Posts:
    840
    That sounds like it would work. I just don't know how to do that...yet. I'll look into that and see if I can come up with that solution.
     
  12. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    You can create a new empty script, inside the Start() function add something like
    VehicleChanger.Instance.character = this.gameObject;
    and add the script to the character prefab.
    I am writing the code off the top of my head but that is the general idea.
     
    dsilverthorn likes this.
  13. dsilverthorn

    dsilverthorn

    Joined:
    May 14, 2017
    Posts:
    840
    Thanks. I'll give it a try. Very much appreciated!
     
  14. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    11.21f

    22/05/2023
    • [WC3D] Fixed bounce caused by the native collider getting enabled at or below the ground level, when impacting at high velocity.
    • [SteeringWheelInputProvider] Changed the VehicleController get method to use Vehicle.ActiveVehicle.
    • [SteeringWheelInputProvider] Fixed DamageHandler null reference bug. DamageHandler is no longer required and all the collision data is retrieved directly from the VehicleController.
    • [SteeringWheelInputProvider] Added deadzones for all axes.
    • [Vehicle] Added Vehicle.ActiveVehicle which replaces VehicleChanger.ActiveVehicle. This removes the dependency of multiple scripts on VehicleChanger. Also makes the demo scripts work without it.
    • [Vehicle] Added 'isPlayerControllable' option. If this is set to false the vehicle will never be set as Vehicle.ActiveVehicle. Useful for trailers and other passive vehicles as the ActiveVehicle is always the last enabled vehicle.
     
  15. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    11.22f

    29/05/2023
    • [SteeringWheelInputProvider] Added device filtering to prevent the LogitechGSDK grabbing the wrong device (gamepad, etc.)
    • [ClutchComponent] Slightly changed the way clutch transmits angular velocity to prevent stalling in neutral.
    • [EngineComponent] Tweaked the engine idle RPM to be closer to the target.
    • [TrailerModule][TrailerHitchModule] Set the trailer attachment layer to 0 by default (Default layer) from the current 25.
    • [DamageHandler] Moved the onCollision event from the DamageHandler to VehicleController to be able to subscribe to onCollision even when no DamageHander is present.
    • [VariableCenterOfMass] Fixed null issue when the GameObject is disabled.
    • [Vehicle] onActiveVehicleChanged now passes previous and current vehicles as params.
     
    TokyoWarfareProject likes this.
  16. MeteTurkay

    MeteTurkay

    Joined:
    Nov 10, 2022
    Posts:
    10
    Hi, i made my own vehicle changer script for different purposes, i want my vehicles to be disabled in scene, so i disabled all vc in vehicle prefabs, but wheel controllers still up, if i disable wheel controllers wheels collider does not work, i guess i would be better if they wouldn't work for better performance? what can i do? Thanks.
     
  17. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    WheelController(3D) is the replacement for WheelCollider, so yes, if you disable the WheelController it will stop keeping the vehicle up in the air. The performance impact of the WheelController is quite low, but if you want you can constrain the Rigidbody before disabling everything to keep the vehicle from falling once the wheels are disabled.
     
  18. TokyoWarfareProject

    TokyoWarfareProject

    Joined:
    Jun 20, 2018
    Posts:
    814
    may be an alternative to constrains could also be to enable a box or simple collider that keeps the car in the air, yet can interact in case of a crash.
     
  19. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    You could, but I decided to not go with such approaches for the latest versions since I did not want to rely on fixes, and instead made sure WC3D is fast by default.
     
  20. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    NWH Vehicle Physics 2 is on sale for two more days.
    Check the link in the signature below.
     
  21. TokyoWarfareProject

    TokyoWarfareProject

    Joined:
    Jun 20, 2018
    Posts:
    814
    No, I did not meant to add it into the package, I meant to the other user that seemed to have issues with the weel collider. In my personal oppinion the cleaner the package is the better. Each dev must implement whatever elses to fit their project.
     
    NWHCoding likes this.
  22. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    The NWH Vehicle Physics 2 sale is ending today.
     
  23. MeteTurkay

    MeteTurkay

    Joined:
    Nov 10, 2022
    Posts:
    10
    Hi, i got a new bug, i dont know ho do i do this but i continually changing vehicles with prev and next buttons to test my vehicles, sometimes even there is no input on throttle or brake, vehicle keep moving the last input i gave, if i press throttle and vehicle acc a little that way, even i stop pressing vehicle keeps increasing speed and gears works too, if i change acc to back pressing brake, same thing happens and vehicle keeps going back, if i dont press enough to change move direction(if moving forward, i need to press brake input) vehicle keeps going that way. if acc changes a little bit reverse direction of vehicle, vehicle keeps going that way even i cut the input. i hope it helps. Thank you.
     
  24. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    First, make sure to update to the latest version.
    Also, you might want to check the option of Input > Swap Input In Reverse which when disabled makes the S always acts as a brake and W always act as throttle, which might be what you want (independent of the direction of travel). I hope I understood the question.
     
  25. MeteTurkay

    MeteTurkay

    Joined:
    Nov 10, 2022
    Posts:
    10
    bug is vehicle keep moving towards the way it acceleration even if i stop pressing button, its act like im pressing, the gears going up, but there is no input

    I guess it happens when we change vehicles too fast
     
    Last edited: Jun 7, 2023
  26. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    Which version of the asset is this? Also, try unplugging any controllers, wheels, etc.
    I have been working on an update for the asset the past few days and definitely did not have the behaviour. Any specifics that I should be aware of?
     
  27. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    11.23f

    09/06/2023
    • Added Lancia Delta demo vehicle which is a replacement for current Lada Niva (which is still included with the asset).
    • Fixed errors after removing .asmdefs from the NWH folder. Clean import required!
    • Re-added ARB (anti-roll bar).
    • Adjusted default clutch slip torque value to be higher when set by the VehicleSetupWizard.
    • Fix trailer layer issue.
    • Fix SoundManager staying disabled after removing FMOD.
     
    TokyoWarfareProject likes this.
  28. argibaltzi

    argibaltzi

    Joined:
    Nov 13, 2014
    Posts:
    220
    Any chance for a DOTS version of this package?
     
  29. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    Not in the planning at the moment. DOTS is still not that popular and it would require a rewrite of the whole asset. The focus now is to add support for FMOD, tracked vehicles, etc.
     
    Willbkool_FPCS likes this.
  30. EnesZuuks

    EnesZuuks

    Joined:
    Dec 1, 2022
    Posts:
    13
    Hi,

    I use motorcycle module wrapper. I wanna limit speed while motorcycle goes reverse. I attempt on speed limiter module wrapper by giving minus values for speed limiter module wrapper's parameter. But I cannot limit speed. Also I cannot solve with gear index values, too. Can you update speed limiter module wrapper to limit reverse going, if I wanna please?
     
  31. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    Speed limiter value should always be positive (field value). I have added this to the TODO and will ship it with the next update.
    You could limit it by increasing the reverse gear ratio, e.g. if the current value is -8 for reverse, putting in -16 will halve the top speed given the same engine rev limiter RPM.
     
  32. SpookyCat

    SpookyCat

    Joined:
    Jan 25, 2010
    Posts:
    3,767
    Will you update the demo to have the Lancia in?
     
  33. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    The main demo scene already has it, I just have not updated the builds yet.
     
  34. EnesZuuks

    EnesZuuks

    Joined:
    Dec 1, 2022
    Posts:
    13
    Thanks for reply man. No matter how much I increase gear ratio value, it does not go down from a certain speed. I'm waiting your update impatiently :)
     
  35. wechat_os_Qy0xzEsbsAc9H8Nsl2wRCUP6w

    wechat_os_Qy0xzEsbsAc9H8Nsl2wRCUP6w

    Joined:
    Jun 24, 2020
    Posts:
    10
    I'm making a software to simulate a real vehicle. First gear needs to control the speed according to clutch lifting, but this is not easy to achieve. What parameters should be adjusted for this? Do you have specific data
     
  36. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    The clutch, when set to manual, works very similar to what a normal clutch would behave like. Also, make sure to update to v11.23f as there were some changes to the clutch fairly recently. And make sure that the slip torque is not too large, it should be somewhat larger (e.g. 50%) than the engine max torque which you can see under the Engine tab.
     
  37. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    I was just looking into this and speed limiter is definitely working both in forward and reverse. I tried setting 5 m/s as the speed limit and it did not go over that both in forward or reverse.
     
  38. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    11.24f

    26/06/2023
    • Flattened the demo scene to 50% height.
    • Added extrapolation to the SkidmarkGenerator to prevent skidmarks from being generated behind the wheel.
    • Fixed variable CoM combined mass affector is never applied.
    • Fixed first mass affector is skipped.
    • Implemented @Nutter fix for bottoming out.
    • Fixed WheelController ? link leads to wrong website.
    • Added forced induction to the engine load calculation.
    • Changed forced induction range to 1,2 from 0,2.
    • Re-introduced friction based on camber (lateral only, simplified).
     
  39. fdameronut

    fdameronut

    Joined:
    May 15, 2018
    Posts:
    11
    Whatever changes you made, you broke it. My car setup has transmission output going to the rear differential and now instead of jumping off the starting line like it did before, it moves at a snails pace.
     
  40. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    The only change that could have any effect is the bottoming out change, the rest are minor or have no effect on physics. The camber one is only for extreme angles (e.g. 30 and more degrees). Could you go to the WheelController.cs, search for 'threshold' and in that line replace the spring.length with spring.maxLength?
    If that does not change it, go to the friction update function and find the Vector3.Dot between the wheel.up and the normal, the variable should be called something along the lines of camberCoefficient, and make it always be 1f.
    Other than that there should be no physics changes. Sorry for the rough instructions, I am on the phone at the moment
     
  41. fdameronut

    fdameronut

    Joined:
    May 15, 2018
    Posts:
    11
    No luck. Tried your suggestions and that didn't help. Put the tags BACK into the friction material presets(why is it you don't have them already populated?) and that still didn't help. Changed the dimensions and even changed the cog and that still didn't help. I am basing the surface friction off of the tag settings.
     
  42. fdameronut

    fdameronut

    Joined:
    May 15, 2018
    Posts:
    11
    Updated to the update published today, no luck. Changed the friction circle strength and that fixed it.
     
  43. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    Sorry for the late reply, I was off for the weekend. Did this fix the tag issue you had earlier? Also, with which value of friction circle did it not work?
     
  44. trvalorantbeta

    trvalorantbeta

    Joined:
    Jul 20, 2023
    Posts:
    1
    Does anyone know about this problem or its solution, encountering either excessive jittering when using network transforms for online synchronization with mirror networking, or flawed synchronization when using Network Rigidbody?
     
  45. wechat_os_Qy0xzEsbsAc9H8Nsl2wRCUP6w

    wechat_os_Qy0xzEsbsAc9H8Nsl2wRCUP6w

    Joined:
    Jun 24, 2020
    Posts:
    10
    I encountered a problem. The speedometer and Tachometer display NaN. I suspect that there is a place that is 0/0, but I just can't find it:(
     
  46. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    That is a bit curious. The speed is derived directly from the Rigidbody so that is not the issue. What script are you using to display the values?
     
  47. wechat_os_Qy0xzEsbsAc9H8Nsl2wRCUP6w

    wechat_os_Qy0xzEsbsAc9H8Nsl2wRCUP6w

    Joined:
    Jun 24, 2020
    Posts:
    10
    DashGUIController And AnalogGauge in demo,also we find this log:Infinity or NaN floating point numbers appear when calculating the transform matrix for a Collider. Scene hierarchy path "Global/Car/CarModel/WheelController/WheelR1_WheelController/Rim MeshCollider". And in this case, the vehicle cannot ignite。
     
    Last edited: Jul 22, 2023
  48. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    That is curious, because the inverse transform is done to convert get the local velocity, but at no point should the vehicle transform be null. At this point I am assuming you are probably doing something differently than it would be usual, since those scripts have been there for years and no bug reports on them so far. Do you have some kind of custom game logic, how are you spawning the vehicle, etc.?
     
  49. wechat_os_Qy0xzEsbsAc9H8Nsl2wRCUP6w

    wechat_os_Qy0xzEsbsAc9H8Nsl2wRCUP6w

    Joined:
    Jun 24, 2020
    Posts:
    10


    It is my log. I directly placed the car in the scene without loading the code
     
  50. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    That is the Vehicle.cs which is used across multiple NWH assets, and has been the base class of all the vehicles for a long time. Can I ask what the scaling on your vehicle is? Because you are getting a NaN on a value reported by Unity, namely vehicleRigidbody.velocity which means that the internal value of the Rigidbody velocity is NaN. My guess is that this is caused by possibly a NaN force being applied to the Rigidbody, which might be caused in some other script and NaN propagation gets the velocity to be NaN.
    Also, could you check if this is happening with the demo vehicles in your scene?