Search Unity

  1. Looking for a job or to hire someone for a project? Check out the re-opened job forums.
    Dismiss Notice
  2. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Wheel Controller 3D - Customizable Three Dimensional Alternative to WheelCollider

Discussion in 'Assets and Asset Store' started by NWHCoding, Nov 17, 2016.

  1. FlightOfOne

    FlightOfOne

    Joined:
    Aug 1, 2014
    Posts:
    400
    Will the Wheel Collider asset get the update also?
     
  2. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,239
    There was a misunderstanding. I was talking about the WheelController3D and bringing it up to date with NWH Vehicle Physics 2. The update just got released for WheelController3D some 2 hours ago. NWH Vehicle Physics 2 has still not been approved because that is a new asset and those take longer to approve.
     
  3. FlightOfOne

    FlightOfOne

    Joined:
    Aug 1, 2014
    Posts:
    400
    Got it! Thank you for the continued years of support! I can't speak for everyone but I will gladly pay for a new WheelCollider3D 2020 :) if only to support you.

    Also, I sent you an email regarding a gc issue (old issue) that was coming up several days ago asking your previous fix would work for the last version. You had sent me a fix for this while back (few versions ago) and I had to apply this to the last version and it seem to still work. Do you know if this new update include that fix? I can send you the email again if you want.
     
  4. ayellowpaper

    ayellowpaper

    Joined:
    Dec 8, 2013
    Posts:
    40
    Hey NWHCoding,

    first of all I got your package yesterday and it made a good impression. It seems to be very solid and has improved the believability of our vehicle a lot. But while the spring feels much better as the standard Unity WheelCollider, we have some issues with it. Our goal is to have very smooth, responsive springs when driving over objects, which the controller does, but avoid "jumpy" behaviour when the vehicle has high velocity. See this video:

    https://imgur.com/a/kU8j9G8

    The car bounces up immensely. We want to reduce that. Similiar behaviour can happen when driving very fast and hitting a slope, the car bounces up by a lot, like a bouncy ball, making it even harder to control. Furthermore we have reduced gravity in our project which increases the seen effect further. What's your advice on reducing bounce of the vehicle caused by springs?
     
  5. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,239
    Hello,
    there are two things here - much as in real world:
    - Damper bump settings - force applied on damper compression. Faster the compression, higher the force - up to a point.
    - Bottom out force - since v4.1 (lastest version) there is a setting where you can adjust this. When the spring travel reaches the limit this force is applied to keep the vehicle above the ground. You can try setting this to 0 or different values <1 and using the body collider to handle bottoming out instead in which case make sure that the physics material on the body collider has bounce set to 0.

    Your issue is more than likely bottoming out. You are dropping a vehicle from quite a height and it gains a lot of speed going down. If we consider that FixedUpdate is running once per Time.fixedDeltaTime and that the spring is quite short is
    quite possible to go from spring being fully extended to fully compressed (or overcompressed) inside a single physics frame. That is why the bottoming out mechanism is there.
     
  6. VagabondOfHell

    VagabondOfHell

    Joined:
    Sep 17, 2013
    Posts:
    14
    Hi @NWHCoding

    I recently purchased this through NWH V1 and have been messing around with it.

    One thing I've noticed is due to how the later masks are set up there can't be vehicle-to-vehicle collisions such as driving on the top of the bus. In this case this could be worked around by adding a collider on the bus roof and maybe sides in case it toppled.

    However, in my case I'd like to do something like a steamroller, and the large wheel should be able to roll over other vehicles that may not have the height of a bus and therefore become more difficult to work around.

    One thing I've tried so far that seems to work is to add a mesh collider on the render portion of the wheel and playing with additional layers, but that can affect the contacts against slopes for the wheel collider (where the mesh collider impacts the terrain and prevents the wheel collider from trying to 'roll' up it)

    Would you have any suggestions to go about this, or any code changes I could make to help with this?

    I thought of adding in some sort of collider check, but that would require me changing the raycasts to be RaycastAlls and filtering out all colliders of the parent rigidbody. Is this something you think would be worthwhile to move forward with or would this cause more problems than it would solve?

    Thank you
     
    Last edited: Apr 27, 2020
  7. ElanGr

    ElanGr

    Joined:
    Mar 10, 2019
    Posts:
    3
    Hi,
    Is there an easy way for me to link the back two wheels of my vehicle together so as if they were connected so that the both spin at the exact same speed, even if one's rotation is being obstructed? Thanks.
     
  8. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,239
    Hello and sorry for the slow reply. Unity forums seem to have issues with notifications when multiple threads are watched. Please contact me over email for faster response times (mail in signature).
    There is no such feature in WheelController3D. NWH Vehicle Physics 2 (my other asset which uses WheelController3D) has a physics solver which applies torque to the opposing wheel to keep the two in sync which is the best way to do it but can be a bit tricky. So besides motor and brake torque inputs you would also apply negative torque to the faster spinning wheel and equal but positive torque to the other wheel.
     
  9. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,239
    Hello and sorry for slow reply. As mentioned in previous post Unity seems to sometimes not notify about forum posts.
    You are correct about this. The layers are used because the performance is great and the filtering is done down deep in the physics engine so there is little (almost no) overhead. What could also be done is checking for the ID of the parent object instead but this would certainly be more costly.
    Still, a good idea and will possibly be added as an option.
     
  10. leventalpsal

    leventalpsal

    Joined:
    Apr 10, 2015
    Posts:
    6
    Does this 4.1 update or NVP2 solves the "vehicles sliding slowly on non-flat surfaces" problem? "Freeze when still" is not a good option for me as it has some unwanted side effects in my application.
     
  11. D_Cergy

    D_Cergy

    Joined:
    Feb 18, 2015
    Posts:
    16
    I am working on my game which uses pathfinding and this asset. It is working well with proper setup and a stable vehicle.
    I did sampling a point in front of the car which generated by the pathfinding and turn the wheel toward that direction.
     
  12. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,239
    Hello, I would suggest checking out the demo and deciding for yourself how you like the behavior.
     
  13. D_Cergy

    D_Cergy

    Joined:
    Feb 18, 2015
    Posts:
    16
    @NWHCoding
    Hi,

    1. I am wondering what is causing a momentary surge of force that happens after the vehicle released from a stuck or sudden stop by landing facing backward? I am constantly accelerate my car and turned off the power if isGrounded false. How do I remove this behaviour?

    2. How do I achieve a constant speed of my car? It will slows down whenever it hit something and accelerating gradually.
    Do you have a suggestion to redirecting the vehicle upon collision and maintaining its velocity?

    3. How to correctly add an instant boost like nitro? Should I force the body, adjusting the WheelController values or anything else? I have the VehiclePhysics which implemented that, but it is overkill for this project.

    Thanks
     
  14. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,239
    Hello,
    I would first like to point out that WC3D is a replacement for WheelCollider and not a vehicle controller. If you need a vehicle controller check out NWH Vehicle Physics 2 (http://nwhvehiclephysics.com).

    1. If the wheels are spinning before hitting the ground they will have kinetic energy stored in that rotation. Once they touch the ground that kinetic energy is instead transferred through friction and propels the car forward. Note that WheelController3D does not have a hard cap on wheel RPM - i.e. since the provided vehicle script just sends torque to the wheel it can spin almost infinitely fast.

    2. In NWH Vehicle Physics there is a CruiseControl module that uses PID controller to maintain vehicle speed by using speed as input variable and throttle/brake position as output variable. PID controller is probably the best realistic solution.

    3. Normally boost means NOS or something similar. In that case you just need to increase the torque sent out by the engine to the wheels - that is how it is done in real world. Alternatively, you could apply the additional force towards the front of the Rigidbody. This would work in the air too if needed.
     
  15. D_Cergy

    D_Cergy

    Joined:
    Feb 18, 2015
    Posts:
    16
    Thank you for the reply.
    Yes, I have the NWH Vehicle Physics 2 as well and it is a great complete solution written in a neat modular structure.
    At first I am trying to build upon that, but I am having difficulties to modify it since the structure become more complex. I ended up using the basic WheelController3D as I only need the basic feature of it and only need minor modifications for my need. Thanks for the advice, I will have a try.
     
  16. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,239
    Understood. You would not use NVP2 for a mini game. Maybe I should make a minimalistic vehicle controller sometime :)
    Also, please join the Dicord channel for faster response times: https://discord.gg/ubFBbM8
    I only check the forums a few times a day.
     
  17. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,239
    Wheel Controller 3D (standalone asset) is getting the update to match the version of Wheel Controller in NWH Vehicle Physics 2 v1.3.1. This features greatly improved friction model, anti-creep for static friction, accurate suspension bottoming out and other improvements and bug fixes.

    The code will be exactly the same since between the standalone version and NWH Vehicle Physics 2 since I am symlinking it between the two.
     
  18. Yany

    Yany

    Joined:
    May 24, 2013
    Posts:
    33
    Hey people. Can I use this great asset to handle wheel physics when the car is rotated in different directions around the z and/or x axis? Will I have a working physics when I drive the car through a loop? (cars upside down)

    Are the rays checking collision downwards in WORLD coordinate system or they shoot downwards locally relative to the rigidbody's rotation?
     
  19. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,239
    Hello. Yes it will. Unlike the WheelCollider (Unity default) WheelController3D follows the orientation of the parent object at all times. So driving around loop is indeed possible.
    I would suggest checking out the demo for NWH Vehicle Physics 2 which uses WheelController3D for its wheels with only minor changes from the standalone WC3D asset. The scene even has a loop so you can try it out for yourself.
    http://nwhvehiclephysics.com/doku.php/Demos
     
  20. Thane_5

    Thane_5

    Joined:
    Sep 22, 2020
    Posts:
    1
    Hey, will this asset go on sale at the 17. November?
     
  21. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,239
    I am afraid not.
     
  22. the_mr_matt

    the_mr_matt

    Joined:
    Jul 21, 2015
    Posts:
    123
    Hello!

    I'm having difficulty with my vehicle flipping in out of control in the air after driving over small objects. It seems that any object that touches the wheel makes it fly, although not reliably, it doesn't always happen.

    This is the configuration:
    Code (CSharp):
    1. Vehicle mass: 1000
    2. Wheel mass: 20
    3. Spring max force: 16000
    4. Spring max length: 0.35
    5. Bottom out force coefficient: 20
    6. Damper bump force: 4000
    7. Damper rebound force: 4400
    8. Arcade friction preset, B = 4, C = 1, D = 2, E = 0.5
    9. Longitudinal and lateral slip and force coefficients: 1
    10. Max tire load: 9600
    11. Max tire grip force: 10200
    Any ideas to improve the stability of the wheels?
     
  23. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,239
    This might be either the vehicle bottoming out and that bottom out force coefficient (which is quite high - 1 is default if I am not mistaken) making the wheel over-react OR the layer mask for the wheel is not set correctly so when the wheel compresses it actually detects the vehicle as ground. In the first case you would get one large jump and in the second case you would get a vehicle that flies into the air or spins until you exit the play mode.
     
  24. the_mr_matt

    the_mr_matt

    Joined:
    Jul 21, 2015
    Posts:
    123
    My issue sounds characteristic of the first case you mentioned. I'll try lower it and see how it performs.
     
  25. the_mr_matt

    the_mr_matt

    Joined:
    Jul 21, 2015
    Posts:
    123
    That definitely improved it, however some vehicles still experience occasional issues.

    Here's another configuration that flipped a car when driving over a small object at high speed. It flipped in the air twice and landed on the ground again.

    Code (CSharp):
    1. Vehicle mass: 1000
    2. Wheel mass: 20
    3. Spring max force: 32000
    4. Spring max length: 0.5
    5. Bottom out force coefficient: 0.5
    6. Damper bump force: 10000
    7. Damper rebound force: 10000
    8. Arcade friction preset, B = 4, C = 1, D = 2, E = 0.5
    9. Longitudinal and lateral slip and force coefficients: 1
    10. Max tire load: 9600
    11. Max tire grip force: 10200
     
  26. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,239
    Could you just try bottom out force coefficient of 0 just to rule that one out. Alternatively, you could send me a repro project so I can see what is happening. WC3D standalone is one version behind NVP2 but things like this still should not happen.
     
  27. the_mr_matt

    the_mr_matt

    Joined:
    Jul 21, 2015
    Posts:
    123
    Bottom out force coefficient of 0 does appear to be more stable. It's hard to know exactly, the issue is intermittent.
     
  28. the_mr_matt

    the_mr_matt

    Joined:
    Jul 21, 2015
    Posts:
    123
    I'm now having difficulty with my vehicles vibrating when stationary. Looking at the rigidbody info I can see they have a very small velocity. This causes other rigidbodies sitting on top of the vehicle to slowly slide and fall off the vehicle, even when the vehicle isn't actually moving. The issue disappears when I make the car kinematic or disable the WheelControllers. This seems like an issue that would be resolved with ConfigureVehicleSubsteps with Unity wheel colliders. Is there an equivalent for WheelControllers? Or any other ideas that might help fix vibrations?
     
  29. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,239
    Hello and sorry for the issues.
    You are correct about the substeps and I have implemented this just recently with NWH Vehicle Physics 2 and will be bringing it in a few days time to WheelController3D standalone (this asset).
    Cases where vibration might happen is rigidbodies with low inertia or ones where the wheels are far away from the body.
    In the meantime both can be fixed by making sure that the vehicle collider has about the same footprint as the vehicle or lowering the center of mass a bit. Using 0.016667 as Project Settings > Time > Fixed Delta Time is usually a good idea too so that the physics runs at 60Hz instead of 50Hz default which makes things overall more pleasant to the eye.
     
  30. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,239
    Wheel Controller 3D v5.0 is on the way with the following changes:
    * Updated to match NWH Vehicle Physics 2 v1.5.
    * Folder restructure to allow for seamless import when other NWH assets are present. CLEAN IMPORT REQUIRED.
    * Implemented physics sub-stepping for tighter friction calculation.
    * Fixed major damper bug. Vehicles might need to be adjusted with ~50% lower bump and rebound values.
    * Reworked friction.
    * Added option to show/hide advanced settings.
    * Other minor bug fixes, improvements and performance optimization.

    Asset has been submitted for review and should be visible within 2 work days.
     
  31. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,239
    v5.0 is out!
     
  32. Yany

    Yany

    Joined:
    May 24, 2013
    Posts:
    33
    Thank you for your thorough answer. I'll definitely give it a go. A few years before I bought the Wheel Controller 3D and if I'm not mistaken you merged the code together and since then everything NWH Vehicle Physics have related to the wheels already included in the WC3D, so I'll check it soon. Thanks again.
     
    Last edited: Nov 23, 2020
  33. the_mr_matt

    the_mr_matt

    Joined:
    Jul 21, 2015
    Posts:
    123
    Thanks for the update! Are you able to give some pointers on how the friction and damping has changed? The handling on my vehicles feels very different after this update and I can't figure out exactly what to change to restore the handling.

    I'm also still getting subtle vibrations. I see there's now OnPhysicsSubstep, is there a way to configure the substeps though? Apparently the way to fix these vibrations with the standard wheel collider is to configure the substeps but I can't seem to do this. Do you think this will fix the vibrations anyway?

    I'm also getting an error. This seems to be repeatable when any rotation constraint is applied to the RigidBody.
    Code (CSharp):
    1. Assertion failed on expression: 'CompareApproximately(SqrMagnitude(result), 1.0F)'
    2. UnityEngine.Quaternion:Euler(Vector3)
    3. NWH.NPhysics.NRigidbody:Step() (at Assets/NWH/NRigidbody/NRigidbody.cs:354)
    4. NWH.NPhysics.NRigidbody:FixedUpdate() (at Assets/NWH/NRigidbody/NRigidbody.cs:227)
     
  34. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,239
    Hello,
    the main change is damper which should be weakened by about 50% (there was a bug in previous version with dampers not working properly at high spring velocities) and the friction which is now more accurate and less grippy. I intentionally published this one as a major release (v4 to v5) due to the amount of changes.
    Substepping is adjustable on the NRigidbody (on the same object as Rigidbody). It gets added automatically if not already present.
    NRigidbody does not support rotation constraints and that could be the reason you are getting the issue. Could you use drag instead (values of 100 or higher) which is supported?
     
  35. the_mr_matt

    the_mr_matt

    Joined:
    Jul 21, 2015
    Posts:
    123
    Hello!

    Just wondering what platforms this asset supports. In particular, I'm hoping my game can support Nintendo Switch, other consoles, and potentially mobile. Will this work?
     
  36. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,239
    I have not tested it on Switch but from the technical standpoint it should work fine on all Unity-supported platforms as only the base Unity physics is used. From a performance standpoint having a lot of vehicles with high quality settings might be an issue, but with a few you will be fine.
    In fact, according to a Discord poll that I made about 50% of the customers of NWH Vehicle Physics 2 (which uses WheelController3D for its wheels) use it on console or mobile.
     
    the_mr_matt likes this.
unityunity