Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

Wheel Collider issues on Unity 5

Discussion in 'Unity 5 Pre-order Beta' started by tonemcbride, Feb 4, 2015.

  1. tonemcbride

    tonemcbride

    Joined:
    Sep 7, 2010
    Posts:
    1,089
    Hi,

    We use 4 wheel colliders on our vehicle - this worked fine on Unity 4.6 but switching to Unity 5 has stopped it working correctly. The wheel colliders seem to penetrate the ground and prevents the car from moving around correctly. I did a few tests and noticed that in Unity 5 the wheel collider seems to move in strange directions whenever the suspension length is changed, this doesn't happen in Unity 4.6

    Here's some videos of me adjusting the suspension length - in the Unity 5 video you can see the whole collider moving strangely compared to the 4.6 version:

    Unity 5 - https://dl.dropboxusercontent.com/u/13097940/unity5.mov
    Unity 4.6 - https://dl.dropboxusercontent.com/u/13097940/unity46.mov

    Has anyone else had problems with wheel colliders when moving to 5 or are there any known 'gotchas' that I'm missing?

    Thanks,
    Tony
     
  2. Meltdown

    Meltdown

    Joined:
    Oct 13, 2010
    Posts:
    5,822
    The wheel collider implementation in Unity 5 has been totally overhauled, you can't just upgrade and expect it to work.

    The Unity 5 upgrade guide has a short document on setting up Wheel Colliders in Unity 5. But other than that there seems to be very little information.
     
  3. tonemcbride

    tonemcbride

    Joined:
    Sep 7, 2010
    Posts:
    1,089
    I understand that and have read all the documentation but I would still expect it to work in some form - from the attached videos it looks more like a bug to me than a difference in functionality.
     
  4. Meltdown

    Meltdown

    Joined:
    Oct 13, 2010
    Posts:
    5,822
    If you read the documentation and went through the example you'd see how it now uses a totally different API and method of implementation. It is not a bug.
     
  5. tonemcbride

    tonemcbride

    Joined:
    Sep 7, 2010
    Posts:
    1,089
    It's ok, I managed to isolate it to a single object in the scene and it appears to be a bug - I've reported it with the test scene. I was told that "Wheel colliers are a known bug in 5.0" so it seems that Unity knows about it already.
     
  6. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    AFAIK it's fixed in RC1. This is a bug where at fast speeds, the suspension stretches. Please confirm with latest public beta (after 22 - should be RC1) when it comes out - hopefully any time the web team gets to it.
     
  7. tonemcbride

    tonemcbride

    Joined:
    Sep 7, 2010
    Posts:
    1,089
    Thanks, I noticed RC1 was just out so I'll download it and try. The problem I was having was also happening when the game wasn't running too so I'm not sure if it's the same thing but will let you know either way.
     
  8. Carpe-Denius

    Carpe-Denius

    Joined:
    May 17, 2013
    Posts:
    842
    I did some tests last week, the wheel collider was working fine for me. I had no ground penetration nor a strange suspension direction.
     
  9. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    I noticed some issues with wheel collider in situations where a vehicle is badly set up, if you get such a situation, please report a repro scene + bug.
     
  10. tonemcbride

    tonemcbride

    Joined:
    Sep 7, 2010
    Posts:
    1,089
    I've tried it on RC1 and the issue is still there unfortunately. Here's a link to a test scene I've made to show the problem:

    https://dl.dropboxusercontent.com/u/13097940/PhysicsTest_Unity.zip

    If you load the test scene and select the game object in 'scene' view you can see the problem fairly easily. Just move the centre of the capsule collider around and the wheel collider moves in all sorts of weird directions. If you adjust the suspension distance on the wheel collider it no longer moves vertically either.

    Here's a video of me moving the capsule collider around (the wheel collider at the bottom of the screen shouldn't be moving at all)

    https://dl.dropboxusercontent.com/u/13097940/WheelCollider.mov

    If anyone has any suggestions that would be good, perhaps there's something I'm doing wrong but I can't see anything obvious - it all works fine on Unity 4.6.

    Thanks!
     
  11. Carpe-Denius

    Carpe-Denius

    Joined:
    May 17, 2013
    Posts:
    842
    Apparently it is only a problem if you have a collider on a parent game object. I never tried that on a car (never needed to), so I can't help you with that.
     
  12. tonemcbride

    tonemcbride

    Joined:
    Sep 7, 2010
    Posts:
    1,089
    It also seems to be fixed if you disable the box collider sibling object and then save the scene (and reload it). Definitely something odd going on.
     
  13. tonemcbride

    tonemcbride

    Joined:
    Sep 7, 2010
    Posts:
    1,089
    I've found that the wheel colliders move to their correct position if they have their own rigid body but this is a bit useless to me as I want to connect them to a car body that has it's own rigid body. I've followed the beta 5 instructions for creating a basic car but it just doesn't seem to work at all (http://unity3d.com/profiles/unity3d/themes/unity/resources/downloads/beta/unity-5.0-user-guide.pdf). Does anyone have a simple test scene of a car body+4 wheels working in Unity 5?
     
  14. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Hierarchy should be similar to:

    Code (CSharp):
    1.     CAR (contains rigidbody and script)
    2.         COLLIDERS
    3.             whatever (collider)
    4.             whatever2 (collider)
    5.         MESHES
    6.             body (mesh)
    7.             whatever (mesh)
    8.         WHEEL MESHES
    9.             wheel (mesh)
    10.             wheel (mesh)
    11.             wheel (mesh)
    12.             wheel (mesh)
    13.         WHEEL COLLIDERS
    14.             fl wheel (wheelcollider)
    15.             fr wheel (wheelcollider)
    16.             rl wheel (wheelcollider)
    17.             rr wheel (wheelcollider)
    18.    
     
  15. tonemcbride

    tonemcbride

    Joined:
    Sep 7, 2010
    Posts:
    1,089
    Thanks hippocoder, that's pretty much what I had but it's still not working. If I look at the wheel colliders in the scene view the centre points are correct (they match up with the wheel mesh) but the actual collision bits for them are offset incorrectly.

    Here's my test project if you have time to try it on yours - would be good to know if there's something obvious I'm doing wrong: https://dl.dropboxusercontent.com/u/13097940/WheelColliderTest.zip

    Thanks!
     
  16. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    You should have no rigidbodies or anything on the gameobject for wheel colliders other than the wheel collider. You should refer to the guide pdf for Unity 5 which has a vehicle example. Having followed that personally, I can verify it works.

    There is also a fully working vehicle in the standard assets for unity 5, where you downloaded.
     
  17. tonemcbride

    tonemcbride

    Joined:
    Sep 7, 2010
    Posts:
    1,089
    Thanks, I tried that and it didn't make a difference but then I realised my parent object had a non 1,1,1 scale on it - when I changed it the wheel colliders are now in the correct place. The car still jitters around and jumps up in the air everywhere but at least it's sort of working now :) I'll have a look at those examples and see if I can find some better settings for the rigid bodies and colliders.