Search Unity

Assets NWH Vehicle Physics

Discussion in 'Works In Progress' 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. marcrem

    marcrem

    Joined:
    Oct 13, 2016
    Posts:
    153
    Hi again. I noticed while working with my character controller that the demo vehicles are smaller than they should be, making my regular-human-sized character feel like a giant. What would be the best way of rescaling an existing vehicle?
     
  2. rclrobertson

    rclrobertson

    Joined:
    Sep 20, 2018
    Posts:
    8
    Hi @NWHCoding, thanks for the great asset! I have a question for you - in my game I'm trying to add some secondary physics motion on my car, like antennas and some other details. I have tried a couple of different plugins for this and I keep running into the same problem - the objects start to jitter erratically as the car moves, with the effect getting worse the faster the car is traveling. I have tried adjusting the fixed timestep and it doesn't seem to make much difference. Do you know what could be causing this issue?
     
  3. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    783
    Hmm. All the vehicle have been scaled using 1 unit = 1 meter (which is what Unity recommends). For the vehicles for which the dimensions are available online I made sure that they are within a few centimeters from the real-world dimensions. Also, the character controller in the demo scene is the Unity's standard character controller with camera set to about eye level and the cars do not look small. Are you sure you character is up to scale?
     
  4. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    783
    Might I ask how you attached those antennas? I have made sure to only use Rigidbody related functions (AddForce, etc.) so any joints, etc. should work fine (and do as far as I know).
     
  5. marcrem

    marcrem

    Joined:
    Oct 13, 2016
    Posts:
    153
    Meh, my bad! The camera component had an offset, placing the camera a bit higher than the character's eyes. Thank you anyway!
     
  6. rclrobertson

    rclrobertson

    Joined:
    Sep 20, 2018
    Posts:
    8
    Thank you for the fast reply. So far I've tried two assets - DynamicBone and Mega-Fiers. Maybe they aren't the right tools for the job, I just happened to own them already so I tried them both. Is there a better asset that you'd recommend, or even something built into Unity that I could try instead?
     
  7. marcrem

    marcrem

    Joined:
    Oct 13, 2016
    Posts:
    153
    Well, here's a regular character straight out of mixamo
     
  8. rclrobertson

    rclrobertson

    Joined:
    Sep 20, 2018
    Posts:
    8
    So after trying a third plug-in - Jiggle - and encountering the same issue, I messed around with the settings and discovered that changing the Maximum Allowed Timestep to match the Fixed Timestep eliminates the jittering. However, this seems to slow down the physics simulation, often to a large degree, making the car behave unpredictably. I am still learning how physics work in Unity so I don’t fully understand what’s going on under the hood, but maybe this information will help diagnose what’s causing the problem.

    Edit - upon further investigation, it looks like this is only true up to 0.017 fixed timestep and maximum allowed timestep. Any higher and the jittering returns.
     
    Last edited: Jul 30, 2019
  9. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    783
    Ah, that jitter. I misunderstood initially. This one is happening when still due to the nature of calculations at low speeds. There has been some relaxation of slip implemented at lower velocities but relaxing it too much would result in sliding cars when velocity is near 0. I would suggest lowering the center of mass of the vehicle slightly and making sure that colliders on your vehicle extend up to the wheels or even over them, combining those two your should be good to go.
    Also, avoid spring lengths shorter than roughly Time.fixedDeltaTime * 10, e.g. 0.17 for fixed timestep of 0.017.
     
  10. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    783
    Hmm, interesting. The blocks you see on the floor should equal 1m assuming that is the editor grid. The vehicle in question should be ~4.5 meters. You could verify this by placing a cube scaled to 4.5 along Z or X over the car and measuring that way. It is more likely that the roof line of that particular car has been wrongly modeled (a bit on the low side).
     
  11. marcrem

    marcrem

    Joined:
    Oct 13, 2016
    Posts:
    153
    Thanks, here it is
    Screenshot_1.png

    It'd help a lot if I could scale it to fit that 4.5 meters actually. I suppose just scaling the main transform won't do it.I'll work on rigging my own cars then, I was hoping to use this one for a while since it's all properly rigged with the dashboard and everything :D
     
  12. rclrobertson

    rclrobertson

    Joined:
    Sep 20, 2018
    Posts:
    8
    Unfortunately that doesn’t seem to be the same issue. I tried using the sedan in the demo scene, which seems to be set up in the way you described, and still encountered the same problem. Also the issue doesn’t only occur at low speeds - in fact it gets worse the faster the car is going.

    I should point out that the issue doesn’t occur with spring joints attached to the vehicle - those work as expected. It only occurs with the secondary animation assets I mentioned (Jiggle, Dynamic Bone and Mega-fiers). Since it’s happening with several different assets that I’ve tried with NWH, I figured I’d ask for help here first, but I can try contacting those asset developers as well.

    Also, I’m happy to put together a sample project that demonstrates the issue, or record a video if that’s easier. I’m traveling this weekend but I can provide either option when I’m back at my desk on Monday.
     
  13. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    783
    You could try turning on Rigidbody interpolation, that will most likely help a lot with a minor cost in physics accuracy.
    If that does not do it please send a video over to nwhcoding@gmail.com and I will see what could be causing this behavior.
     
  14. rclrobertson

    rclrobertson

    Joined:
    Sep 20, 2018
    Posts:
    8
    Thank you for the reply - I tried turning on interpolation and the problem still exists. I sent over an email with a video demonstrating the issue.
     
  15. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    783
    Clutch for the new physics model is all done and working. It took way longer than expected but I decided to work on it until it works properly. All of you that are doing sims for driving schools and driving schools should now have a proper feeling clutch.
    If set to automatic clutch in 2.0 will be governed by a simple PID controller which means that automatic release will be fully adjustable - slow, fast and everything in between.
    As the vehicle is now for the first time fully driveable using the new powertrain model I will make a small tech demo build in the next few days.
     
    Last edited: Aug 8, 2019
  16. overthere

    overthere

    Joined:
    Jun 28, 2013
    Posts:
    101
  17. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    783
    Interesting. As long as the raised area has a collider of some kind it should work perfectly fine since it uses RaycastCommand to detect the surface shape. I would suggest turning off "Queries Hit Triggers" in Physics settings and trying then in case Digger places a trigger collider of some kind (e.g. as a handle).
     
  18. overthere

    overthere

    Joined:
    Jun 28, 2013
    Posts:
    101
    That was it, thank you for the super prompt response!
     
  19. embeee

    embeee

    Joined:
    Aug 25, 2017
    Posts:
    6
    Hello, quick question: I'm upgrading Unity from a 2018 version to the latest version and would need to reimport my vehicle settings from my backup folder. How can I do this, for example for the Island demo scene? Are the settings stored in a file somewhere?
     
  20. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    783
    If you are upgrading Unity should handle everything for you. No need to do anything special as everything is serialized like every other standard Unity component. Also, the project settings are also auto-upgraded by Unity. Still, it is always a good idea to backup your work before any major upgrade.
     
  21. embeee

    embeee

    Joined:
    Aug 25, 2017
    Posts:
    6
    Hi again, unfortunately when I tried just updating the asset it reset my vehicle configuration, so that's why I'm wondering where the vehicle settings are stored. Are they in the prefab or another file?
     
  22. DeathRace26

    DeathRace26

    Joined:
    May 26, 2019
    Posts:
    28
    Hello
    Can i somehow controll threshold when vehicle freezes if still?(optimization section) I see this option very useful, especially when i crawl on specific surfaces. Sadly this sometimes doesnt work because car is on too steep surface so gradual creep happens even after that. Tire slip is not an option for me, because when i put force coef to 1.4, (and that is really strong force) it still happens

    Thanks for support, im happy customer. Cant wait for improved engine simulation update ! :D
     
  23. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    783
    As promised here is a preview build for the new powertrain model.
    Note that this is in not representative of NVP 2.0 but a small separate project just to demonstrate the progress so far. Not everything is working perfectly and there are many more things to implement.

    https://drive.google.com/open?id=1NStXxFT3lWYPcmQV3AT9xVLu0Mhhv3Rx

    Edit: Forgot to mention that in the build all the diffs are locked and hence the reluctance to steer.
     
    Last edited: Aug 17, 2019
  24. DeathRace26

    DeathRace26

    Joined:
    May 26, 2019
    Posts:
    28
    That's more like it :) It pushed against obstacle and doesnt brake. Thanks a lot for this demo :D Looking forward to 2.0
     
  25. angrypenguin

    angrypenguin

    Joined:
    Dec 29, 2011
    Posts:
    12,066
    Heyo @NWHCoding,

    I'm using NWH Vehicle Physics v1.6 on one of my projects. I've got a small car (~2.5m long), and it has to do a bunch of jumping when moving around the environment. It behaves pretty well when when jumping, but it tends to bounce when landing, which makes it difficult to maintain control. Do you have any suggestions or advice about how to minimize bouncing and maximize control?

    Things I'm considering:
    - Leveling out the car when it's in the air, so all wheels reach the ground at roughly the same time.
    - Aligning the car with it's direction of movement when it's in the air, so the wheels roll rather than grip.
    - Possibly detecting when it hits the ground, and limiting its upwards velocity until it's stable.

    It's a sci-fi car, so the first couple of ideas can work thematically.
     
  26. adrien417

    adrien417

    Joined:
    Jun 4, 2017
    Posts:
    2
    Hey :), work with unity 2019 ?
     
  27. fredastaire

    fredastaire

    Joined:
    Sep 10, 2017
    Posts:
    45
    If anyone can help I’m having an issue with the damage system where my tire mesh receives damage whilst driving in normal conditions with my tag set to nodam on meshes and in damage section set to ignore is there something I am doing wrong?
     
  28. Jbs_GameZone

    Jbs_GameZone

    Joined:
    Dec 14, 2018
    Posts:
    105
    Yes, I'm using it with 2019.2.1.f1 without issues.

    EDIT : Spoke too soon. Has anyone else encountered these memory warnings in IOS builds with Unity 2019.2.1f2 and XCode 11 beta 5 ?

    Internal: JobTempAlloc has allocations that are more than 4 frames old - this is not allowed and likely a leak
    (Filename: ./Runtime/Allocator/ThreadsafeLinearAllocator.cpp Line: 539)
    To Debug, enable the define: TLA_DEBUG_STACK_LEAK in ThreadsafeLinearAllocator.cpp. This will output the callstacks of the leaked allocations
    (Filename: ./Runtime/Allocator/ThreadsafeLinearAllocator.cpp Line: 541)
    Internal: JobTempAlloc has allocations that are more than 4 frames old - this is not allowed and likely a leak
    (Filename: ./Runtime/Allocator/ThreadsafeLinearAllocator.cpp Line: 539)
    To Debug, enable the define: TLA_DEBUG_STACK_LEAK in ThreadsafeLinearAllocator.cpp. This will output the callstacks of the leaked allocations
    (Filename: ./Runtime/Allocator/ThreadsafeLinearAllocator.cpp Line: 541)
    Internal: JobTempAlloc has allocations that are more than 4 frames old - this is not allowed and likely a leak
    (Filename: ./Runtime/Allocator/ThreadsafeLinearAllocator.cpp Line: 539)
    To Debug, enable the define: TLA_DEBUG_STACK_LEAK in ThreadsafeLinearAllocator.cpp. This will output the callstacks of the leaked allocations
    (Filename: ./Runtime/Allocator/ThreadsafeLinearAllocator.cpp Line: 541)


    For the moment the culprit seems to be the VehicleController.LateUpdate() (particle and sound update calls) method call. If I comment it the game runs ok.

    Any feedback if highly appreciated.


    UPDATE : There are multiple reasons why these errors occur on low end IOS devices. One of them are objects that cast or receive shadows. Adding meshRenderer.receiveShadows = false in SkidGenerator.CreateNewSnapShot method, to the newly created skidobjects was one of the fixes. Also check all particles and make sure they don't cast or receive shadows (exhaust & exhaust nos) were the ones that needed to be updated as well (ParticleSystem > renderer setting). So far so good.

    Thanks
     
    Last edited: Aug 22, 2019
  29. CoderPro

    CoderPro

    Joined:
    Feb 21, 2014
    Posts:
    308
    I can not control car !!!
     
  30. GLID3R82

    GLID3R82

    Joined:
    Aug 7, 2013
    Posts:
    10
    @CoderPro

    Press "E" to Start Engine, then WASD or Arrows

    PS: I didn't find reverse gear... so if you are stopped against a wall simply restart PowertrainModel2

    I hope it helps
     
    Last edited: Sep 6, 2019
  31. DeathRace26

    DeathRace26

    Joined:
    May 26, 2019
    Posts:
    28
    Is v2 version going to include Torque calculations? I've seen numerous games with similar physics, but i've chosen this because of wheel detection. Hopefully this new version will include much better engine simulation. No matter what i do, my tires shake when i try going uphill. Throttle limiting did not help. When increasing power too high, car speeds up like lamborghini.
     
  32. KoingWolf

    KoingWolf

    Joined:
    May 20, 2019
    Posts:
    4
    I've been exploring possibly purchasing this asset, but I've run into a pretty substantial snag. When the car reaches higher speeds (above 75+ mph) the collisions become erratic. I brushed a wall and that sent the car flying into the sky, for example. Is there any documentation or possible troubleshooting that I can start to take to correct this? It's the only thing keeping me from fully committing at this point.

    Also, I see talk about a 2.0 version coming soon, will this be a free release for existing customers, discounted, or full purchase price?
     
  33. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    783
    The collision is handled purely by Unity/PhysX and standard colliders. What could be done is possibly adjusting the physics material settings but not much more.

    The 2.0 will either be heavily discounted for the current customers.
     
  34. KoingWolf

    KoingWolf

    Joined:
    May 20, 2019
    Posts:
    4
    Okay, I'll look into it more and see what else I can adjust.
    Any ETA or general release time frame for the 2.0 update? Thank you for the reply!
     
  35. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    783
    There has been a pause in development of 2.0 for the last three weeks but I am starting again in two or three days. I can not yet give accurate ETA since I am not sure how exactky what will be implemented and how, and which technical challenges migh arise. But no less than a month, no more than two.
     
  36. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    783
    The concept of the axles, differentials and wheels will be changed in NVP2.

    NVP1:
    - Vehicle has multiple axles, each axle has left and right wheel.
    - Torque is split in the axle itself since the differential is integrated into the axle, with a slider for torque distribution between axles.

    NVP2:
    - Vehicle has multiple axles with N wheels (leaving space for motorcycles, steam rollers, etc.)
    - Each wheel can belong to one axle (or none).
    - Axles do not have to have a differential at all and the two are in fact completely separate.
    - Axles define steering and braking characteristics (as in NVP1) of the wheels belonging to it. Think of an axle as a wheel group.
    - Power is sent to the wheel(s) by setting the output of any differential (or even directly from transmission, clutch, etc.):
    upload_2019-9-29_14-49-53.png
    This is just a concept that I am implementing at the moment so would like to hear the feedback if any. I am aware that this setup will add a few steps to creating a new vehicle but decided that the options it opens up will be worth it.
    Just note that everything written in here is subject to change.
     
  37. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    783
    A quick update on sound in NVP2:

    upload_2019-10-5_17-4-32.png

    Some changes that have been made:
    - Each sound component can be enabled and disabled individually.
    - If component is disabled when entering play mode it will not be initialized until it is enabled for the first time during play mode.
    - If component is enabled when entering play mode it will be initialized during start.
    - Components can be individually enabled and disabled at run time which will be useful for performance optimization (i.e. disabling some components as player gets further from the vehicle).
    - Sound can also be completely turned off using the master sound toggle (big green button on top). If clicked it disables all the sound components. If clicked again it enables all components that were enabled initially (not all).
     
    Bzuco and xDeveloper like this.
  38. DeathRace26

    DeathRace26

    Joined:
    May 26, 2019
    Posts:
    28
    Is this compatible with microsplat? I keep getting errors every time reaching border of terrain going to another one, here is error with lines:

    Texture rectangle is out of bounds (512 + 1 > 512)
    UnityEngine.TerrainData:GetAlphamaps(Int32, Int32, Int32, Int32)
    NWH.VehiclePhysics.GroundDetection:GetTerrainTextureComposition(Vector3, Terrain, Single[]&) (at Assets/VehiclePhysics/Scripts/Vehicle/GroundDetection.cs:
    233)
    NWH.VehiclePhysics.GroundDetection:GetDominantTerrainTexture(Vector3, Terrain) (at Assets/VehiclePhysics/Scripts/Vehicle/GroundDetection.cs:
    254)
    NWH.VehiclePhysics.GroundDetection:GetCurrentGroundEntity(WheelController) (at Assets/VehiclePhysics/Scripts/Vehicle/GroundDetection.cs:
    206)

    In other cases, everything seems to work fine
     
  39. adrien417

    adrien417

    Joined:
    Jun 4, 2017
    Posts:
    2
    Hey, compatible with Unity ? 2019.2.6
     
  40. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    783
    Yep. It is just that it has been submitted using the last LTS release because Unity does not support downgrading the package to a lower version than that - but you have no problem using a higher version. It has been tested with 2019.1 but noting major changed in 2019.2 that would impact the asset so you are good to go.
     
  41. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    783
    Interesting that it does not work at border but does normally. That would mean that the Terrain reports different texture resolution from what Microsplat uses, somehow. The error basically says that NVP tried to query a texture pixel outside of the size of the texture itself but at the same time NVP also queries the terrain for the texture resolution so all should be good there. Could you check that your Microsplat settings are identical to your terrain settings?
    Also check if there is a compatibility setting in Microsplat that would populate the native Terrain textures - can not remember if this was a setting in CTS or Microsplat anymore.
     
  42. sonicviz

    sonicviz

    Joined:
    May 19, 2009
    Posts:
    1,022
    Hi,
    I'm currently evaluating NWH vs VPP for an upcoming project.

    I see that NVP2 is coming soon and it's tricky to determine at the moment which is the best fit.
    I tried the current demo, and like the suspension model in the monster truck.

    Could you give me some more insight into the following for V2 (if possible):
    • Suspension model and flexibility (including bump/rebound stops and anti roll bars)
    • Tire model (especially slip angles and yaw flexibility for understeer/oversteer).
    • How many contact points does the tire model use?
    [edit] Are all those questions related to https://assetstore.unity.com/packages/tools/physics/wheel-controller-3d-74512 ?
    Is that getting a refresh in V2 as well?
    • Telemetry. What is available to monitor?
    Are you still shooting for end of October ish for V2?

    ty!
     
  43. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    783
    Hello,
    the friction calculation along with suspension will remain as is as that is the part of WC3D which is not the focus of the update. The main focus is powertrain physics, editor itself and the move to modules, along with other things.
    Telemetry is only there to demostrate what is going on in the back end and is pretty much there only for the demo. Normally you would check those values in the editor if you were debugging or pulled out just the info you need for the user.

    At the moment end of October is a bit optimistic. I had another project that used up all my time for almost a month and I have increased the scope of the update from the physics-only update to a much larger update which has moved the dates some.
     
  44. sonicviz

    sonicviz

    Joined:
    May 19, 2009
    Posts:
    1,022
    Thanks for the update.
     
  45. sonicviz

    sonicviz

    Joined:
    May 19, 2009
    Posts:
    1,022
    I picked this up. Is there a handbrake at all? I can't see one.
     
  46. Kmeier

    Kmeier

    Joined:
    Feb 9, 2016
    Posts:
    11
    I saw that V2 will support motorcycles as far as center wheels (one wheel per axle) goes, but will it be officially supported? If not, have you considered making a paid addon?
     
    digiross likes this.
  47. pandey611

    pandey611

    Joined:
    Sep 26, 2013
    Posts:
    12
    I asked you few queries before purchase. No reply from your side.
    I asked you few queries after purchase. Again no reply from your side.
    My email Id is pradeepgshastra@gmail.com .
    Please do check your inbox.
    I am coming here atlast to ask my query. Hopefully I will get my queries answered here.
    I was testing photon multiplayer beta scene. Followed the doc inside photon multiplayer folder.
    I imported the nwh vehicle physics inside new project.
    Then I imported photon classic asset from asset store.
    Then added photon id inside the photon server settings.
    Then added PHOTON_MULTIPLAYER in player settings scripting symbols, as it was mentioned inside readme file inside photon multiplayer folder.
    I created a build.
    Run the build.
    Then run the photon scene inside unity editor.
    Nothing spawns on either side of the builds.
    Nothing shows up on either side of the builds .

    My unity version is 2018.4.2f1
    Please help me out in getting photon scene working.
     
  48. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    783
    Hello,
    yes there is. Under the axle settings you will see a slider named "Handbrake Coefficient". Set this to any value between 0 and 1 (0 if you do not want handbrake on that axle and 1 if you want full handbrake strength on that axle).
     
  49. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    783
    The motorcycles will be a paid module that will work in conjunction with the new module system and will be officially supported. While including motorcycles in the upgrade itself was an option it would rise the price for those that do not need motorcycles and making what is essentially another asset for free is not something I can afford. Can not talk about exact pricing at the moment but it will be a fraction of the cost of the base package.
     
    Willbkool_FPCS likes this.
  50. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    783
    Hello,
    check your email for the reply.
    The issue was that you used PUN v2 and the officially supported Photon Networking in NWH Vehicle Physics is: https://assetstore.unity.com/packages/tools/network/photon-unity-networking-classic-free-1786
    After replacing it and following the steps in the readme it works as intended.