Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

vehicle launched into the air as soon as it comes to rest

Discussion in 'Physics' started by JoeStrout, Oct 26, 2016.

  1. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,859
    I've got a vehicle composed of some box colliders, and some convex mesh colliders (not WheelColliders) for the wheels.

    If I put this on a gentle slope, it works great: it rolls on down the slope, and nothing odd happens.

    But if I put it on a flat plane, it rocks around a little bit (from the initial drop) and then comes to rest... and then launches itself violently into the air.



    I've tried changing the collision detection on both the main Rigidbody and on the wheel Rigidbodies from Discrete to Continuous or Continuous Dynamic (thinking this might prevent them from going to sleep), but it makes no difference.

    I do think it's a failure of collision detection... there seems to be one frame in the image where the wheels suddenly slip down into the ground, and then of course they get ejected with extreme prejudice. But I can't figure out what to do about it. Any suggestions?

    (I have another, simpler two-wheeled vehicle composed of a box and two cylinders, and it's not showing this problem. But, apart from two wheels vs. four, I can't figure out what the difference is. The Rigidbody settings are all the same, including the mass.)
     
  2. kozle

    kozle

    Joined:
    Aug 6, 2015
    Posts:
    46
    Try setting drag of your rigidbodies above 0.
    You can also try changing Solver Iterations and Solver Velocity Iterations.
    The third thing i would try is to give your wheels larger mass.
     
  3. JamesLeeNZ

    JamesLeeNZ

    Joined:
    Nov 15, 2011
    Posts:
    5,616
    lol awesome.

    What is the mass set to?

    Do you have any scripts on it?
     
  4. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,859
    Mass was set to 1 each for the body and each of the wheels. No scripts on it.

    Except that now, I have fixed the problem by attaching a script that sets the sleepThreshold to 0 upon Awake. That appears to keep the rigidbodies from sleeping, which prevents the problem. Feels a bit hackish, but seems to work.
     
  5. JamesLeeNZ

    JamesLeeNZ

    Joined:
    Nov 15, 2011
    Posts:
    5,616
    Yeah I imagine that could happen for a mass of 1. It will be the penetration penalty. Because its so light, its getting thrown up. If it was 1000, I can imagine it would barely move... although needs more investigation