Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Bad Wheel Collider Collision Detection!

Discussion in 'Editor & General Support' started by POLYGAMe, Oct 18, 2009.

  1. POLYGAMe

    POLYGAMe

    Joined:
    Jan 20, 2009
    Posts:
    196
    Hey guys,

    I've got a small racing game up and running but I've noticed that sometimes when the car flips (after doing a jump or something) the wheels on one side go through the ground, where they remain stuck....

    Any ideas?

    This happens both on iPhone and Mac versions.
     
  2. andeeeee

    andeeeee

    Joined:
    Jul 19, 2005
    Posts:
    8,768
    The WheelCollider is actually implemented with a raycast from the wheel's centre. If the car moves sideways quite fast, the whole WheelCollider can move under the ground in less than a single frame time. Once underground, the collider hasn't got anything underneath to collide with and just gets dragged along as if the wheel had broken off.

    This usually happens when the wheel sticks out sideways from the main body collider of the car (you'd probably find this with a racing car, say). You can prevent it from happening by adding some extra colliders that stick out sideways, roughly along the wheels' axles (these are sometimes called "ears"). You'd probably want capsule colliders with a radius about a quarter of the wheel's radius. They should have a slippy physic material and be the same width as the wheel.

    If you still find the wheels can duck under the ground, then try moving the WheelColliders inward slightly so that they are close to the centre line of the ears.
     
  3. POLYGAMe

    POLYGAMe

    Joined:
    Jan 20, 2009
    Posts:
    196
    Thanks! I'll give that a go.
     
  4. POLYGAMe

    POLYGAMe

    Joined:
    Jan 20, 2009
    Posts:
    196
    Worked perfectly, thanks! Now my little truck can jump til his heart's content.
     
  5. ockky

    ockky

    Joined:
    Dec 11, 2009
    Posts:
    18
    I'm currently experiencing exactly what you are describing andeeee but can't quite figure out what you are describing as a solution. I've tried placing (4) capsule colliders at the same position as my wheel colliders. My capsule colliders use the x-axis to take the shape of the wheel, but i've cut the radius of the collider to be smaller than the actual wheel. I've also placed these capsule colliders on the 'ignore raycast' layer in hopes of not interfering with the wheel colliders.

    However, after doing these changes, my car now flips/spins around uncontrollably or just wont move at all at times. prior to these changes, the car drove great, just occasionally would get stuck in the meshcollider that is the track.

    Any clarification would be extremely helpful.
     
  6. GaggiGamer

    GaggiGamer

    Joined:
    Aug 10, 2020
    Posts:
    14
    i wonder that this problem still not resolved officially by Unity. This solution worked for me