Search Unity

  1. Unity 2019.2 is now released.
    Dismiss Notice

Unity 5 - Wheelcolliders sinks into the ground

Discussion in 'Physics' started by mads232, Jul 8, 2015.

  1. mads232

    mads232

    Joined:
    Sep 6, 2013
    Posts:
    48
    After updating from unity 4 to unity 5, I've been having lots of problems with the wheelcolliders.

    I've been reading across google and these forums, and many says they are bugged.

    My problem is, as the title describe, they sink into the ground.
    It was working some time ago, but now it messed up.

    Here's what it looks like:







    Anyone knows how to fix this?
    Could it be caused by the center of mass?

    Please feel free to ask for additional info.
     
  2. JamesLeeNZ

    JamesLeeNZ

    Joined:
    Nov 15, 2011
    Posts:
    5,618
    While I initially thought the wheel colliders were broken, I now dont think that in the slightest!

    your setup looks fine, although its not 100% clear. I assume all your physics layers are set correctly, and the terrain/whatever its sitting on has colldiers etc?
     
  3. mads232

    mads232

    Joined:
    Sep 6, 2013
    Posts:
    48
    I don't know what you mean by physics layers?

    The ground is a big box collider.
     
  4. mads232

    mads232

    Joined:
    Sep 6, 2013
    Posts:
    48
    By the way, aren't the small spheres supposed to be just beneath the initial wheelcollider?
     
  5. mads232

    mads232

    Joined:
    Sep 6, 2013
    Posts:
    48
    Hmm.. This doesn't look right?..

     
  6. JamesLeeNZ

    JamesLeeNZ

    Joined:
    Nov 15, 2011
    Posts:
    5,618
    Generally what I found when I upgraded was that the suspension and slip settings have all been completed changed in U5, and the old settings were incorrect.

    If you just add wheel colliders and dont modify them at all, do you get the behaviour?
     
  7. mads232

    mads232

    Joined:
    Sep 6, 2013
    Posts:
    48
    That fixed it yes, but I really need the current suspension and slip settings, cause it's a forklift. It should be really stiff, and don't rock that much sideways when driving.

    Edit: It does not "fix" it. It just makes it wierd to drive because of the suspension settings.
     
  8. JamesLeeNZ

    JamesLeeNZ

    Joined:
    Nov 15, 2011
    Posts:
    5,618
    ok, thats a good start, so next step is tweeking the settings to find what works.

    Start with the suspension, increase the spring/damper settings.

    These values are affected by rigidbody mass. I would start with a fairly standard 1000 kg (1 tonne).

    start with 1000 for spring, 500 for damper, increase until you find values that work.
     
  9. mads232

    mads232

    Joined:
    Sep 6, 2013
    Posts:
    48
    Well I have the settings that simulates the best physics.

    Is this problem related to the settings?
     
  10. JamesLeeNZ

    JamesLeeNZ

    Joined:
    Nov 15, 2011
    Posts:
    5,618
    Compare your settings to default settings and see where the differences are. Generally the answer would be yes, its related to your settings.

    I don't know what you mean by settings that simulate best physics. Are you talking real-world numbers?

    I go for what feels realistic when im playing the game.
     
  11. mads232

    mads232

    Joined:
    Sep 6, 2013
    Posts:
    48
    What I mean is, I've configured the spring and dampener to be as close to a forklift's real world properties. I just typed in some numbers until I felt like it felt realistic.

    So the only thing I've changed is the spring and dampener
     
  12. JamesLeeNZ

    JamesLeeNZ

    Joined:
    Nov 15, 2011
    Posts:
    5,618
  13. mads232

    mads232

    Joined:
    Sep 6, 2013
    Posts:
    48
    So I should GetWorldPose, and then apply it to the wheel mesh?
     
  14. JamesLeeNZ

    JamesLeeNZ

    Joined:
    Nov 15, 2011
    Posts:
    5,618
  15. mads232

    mads232

    Joined:
    Sep 6, 2013
    Posts:
    48
    Sorry for the late reply. That did not fix it.
     
  16. JamesLeeNZ

    JamesLeeNZ

    Joined:
    Nov 15, 2011
    Posts:
    5,618
    Didnt fix the wheel colliders sinking into the ground?

    Can you show me the code?
     
  17. mads232

    mads232

    Joined:
    Sep 6, 2013
    Posts:
    48
    It is 4:40 AM at my place so I'll get some sleep. I can send the code when I wake up, although I do not have anything that changes the mesh or collider's position or settings.
     
  18. mads232

    mads232

    Joined:
    Sep 6, 2013
    Posts:
    48
    Do you still want the code?
     
  19. minimalic

    minimalic

    Joined:
    Mar 26, 2015
    Posts:
    6
    Rotation of your wheel collider or parent elements seems to be wrong. The "small spheres" should be exactly in the center and at the bottom of your wheel colliders/wheels.
     
  20. mads232

    mads232

    Joined:
    Sep 6, 2013
    Posts:
    48
    Yes, I was suspecting this, although the inspector indicates 0 rotation on all axes. Both the parent and the wheels. Could this be something in blender, if yes, how should i fix this? Blender shows 0 rotation too.
     
  21. JamesLeeNZ

    JamesLeeNZ

    Joined:
    Nov 15, 2011
    Posts:
    5,618
    ignore that guy... he's just going to send you down the wrong track.

    show me the code.
     
  22. mads232

    mads232

    Joined:
    Sep 6, 2013
    Posts:
    48
    Well I'm not going to ignore anyone trying to help. Actually I think he might be right.

    As I already told you, the code changes nothing that much.

    This is something before the code is executed
     
  23. JamesLeeNZ

    JamesLeeNZ

    Joined:
    Nov 15, 2011
    Posts:
    5,618
    ok then... good luck
     
  24. mads232

    mads232

    Joined:
    Sep 6, 2013
    Posts:
    48
    Don't help if you don't want to cooperate with other people.
     
  25. JamesLeeNZ

    JamesLeeNZ

    Joined:
    Nov 15, 2011
    Posts:
    5,618
    I offer help when users give me the information I ask for. If they dont, well they can figure it out by themselves. I'm not getting paid to help people here.
     
  26. mads232

    mads232

    Joined:
    Sep 6, 2013
    Posts:
    48
    I understand that, but I just think it's wrong to tell me to ignore other help. I can assure you that my code does not create this behaviour. minimalic is right. Those spheres should be just below the center of the wheel.
     
  27. DerpMerf

    DerpMerf

    Joined:
    Jan 1, 2014
    Posts:
    33
    Why are you even using Wheel Colliders? Why does anyone ever use anything BUT mesh colliders? How does that even make sense? I believe you should just switch to mesh collider and create your own suspension system. It's much more reliable as far as hitboxes go and just better overall, affording you more ability to customize the way the suspension works.
     
  28. mads232

    mads232

    Joined:
    Sep 6, 2013
    Posts:
    48
    Well it is designed to be used, and in Unity 4 I had no issues with it, so I would love if I could use it in Unity 5 too. Also, I don't want to go through the trouble of creating my own suspension. :)
     
  29. JanetEscGames

    JanetEscGames

    Joined:
    May 2, 2018
    Posts:
    5
    I had this problem - it was caused by the ray direction of the wheel colliders pointing in the wrong direction (should be straight down, as indicated by the small green ball when you highlight the wheel collider.)
     
  30. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    5,656
    @JanetEscGames check the date of previous post. How you even found this thread?
     
  31. JanetEscGames

    JanetEscGames

    Joined:
    May 2, 2018
    Posts:
    5
    I googled the problem, and added the solution I found to help people in the future who googled the problem. If this is against the forum culture I will no longer do so.