Unity Wheel Collider for Motor vehicle

Greetings everyone!

Want to Make a Car Racing Game?

Having troubles with Car Physics?

Where to use Wheel Collider?

How to use Wheel Collider?

What are the components of Wheel Collider?

How is Wheel Collider Different than other Colliders?


Have these Questions in Your Mind?

No worries. You will get a satisfactory answer to all those questions, right here.


GameDev.net: How to Create Homing Missiles in game with Unity

Unity Wheel Collider for Motor vehicle Tutorial 2018

These will give an idea of how to work with wheel collider and physics of Wheel Collider.

Comments

  • Nice tutorial!
    I've toyed around with the Unity wheel stuff, and it works okay at moderate speed. Sometimes when I hit terrain at high velocity the wheels fall through the surface and stick to the other side.
    Any tips on how to avoid this, or worst case, detect this and recover?
  • edited
    I had similar issue when using a Wheel Collider a while back.

    Without looking if the the code provided in the example, I can say that reducing the 'Fixed Timestep' improved this to an acceptable point - using a value of 0.0001 seemed about right for me.

    If you need anything faster, you might as well swap out that spinning wheel and replace it with a pre-made spinning wheel animation, when the wheel revolves at speed beyond a certain amount, and keep the collider from rotating, and swap it back in when it slows down, when it as at more acceptable collision detection rates.... if you know what I am getting at..
    Thanked by 1John
  • "Because cars can achieve large velocities, getting race track collision geometry right is very important. Specifically, the collision mesh should not have small bumps or dents that make up the visible models (e.g. fence poles). Usually a collision mesh for the race track is made separately from the visible mesh, making the collision mesh as smooth as possible."
    See https://docs.unity3d.com/Manual/class-WheelCollider.html and https://docs.unity3d.com/Manual/WheelColliderTutorial.html for the "Official Unity Tutorial and documentation" where they actually explain these collision issues and 'time step' implications in more detail.
  • edited
    Oneil_CT said:
    Without looking if the the code provided in the example, I can say that reducing the 'Fixed Timestep' improved this to an acceptable point - using a value of 0.0001 seemed about right for me.
    That's 10,000 physics updates per second... :/ That'd work... but... ouch. :P

    In the past, I've had some success with making the collision geometry of the world have thickness. I've also tried to raycast when things move (raycast distance dependent on velocity), to check for incoming collisions before they happen and plant my objects where the raycasts hit.
    Thanked by 2Oneil_CT bevis

  • That's 10,000 physics updates per second... :/ That'd work... but... ouch. :P
    Yeah, it seemed OK for a prototype running on WebGL - only one simple scene with one wheel. (Spin`n Win)

    But like you said - make the meshes more pronounced.
    I love your idea of raycasting to predict collisions ahead of time! Neat :)
  • Might try Bullet in Unity. In native Bullet in OpenGL Continuous Collision detection has never given a wheel penetration, even when traveling 65000km/h, one of the advantages of forward versus reverse collision detection. (I think Unity's default behaviour is to check for penetration and then try to reverse out of it, which only works at lowish velocities or with solid intrinsic primitives as @Elyaradine mentioned, )
    Unity's continuous collision mode works a little better than the default.
  • I'm not quite an expert, but I have worked on a lot of games using Wheel Colliders. Unfortunately the Unity Wheel Collider isn't amazing, though some of these approaches sound to me like 10 ton hammer solutions (ie super short time step or a whole new physics engine).

    Generally most people take one of two approaches 1) a custom wheel collider - not for the feint of heart. Or 2) fudge the unity wheel collider. IRC eddies wheel physics from the asset store takes a similar approach. e.g if your problem is the raycasts penetrating the scenery I'd play with TerrainData.thickness or create some kind of custom suspension script that always makes sure the wheel is pushed above the scenery/collider
    Thanked by 1critic
Sign In or Register to comment.