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:
    148
    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:
    759
    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:
    759
    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:
    148
    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:
    148
    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:
    759
    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:
    759
    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:
    148
    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:
    759
    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:
    759
    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:
    759
    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:
    4
    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:
    759
    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:
    4
    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. matees228

    matees228

    Joined:
    May 26, 2019
    Posts:
    22
    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:
    759
    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. matees228

    matees228

    Joined:
    May 26, 2019
    Posts:
    22
    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:
    11,983
    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:
    1
    Hey :), work with unity 2019 ?
     
  27. fredastaire

    fredastaire

    Joined:
    Sep 10, 2017
    Posts:
    43
    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:
    102
    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 at 10:02 AM
  29. CoderPro

    CoderPro

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