Search Unity

Resolved Weird wheelcollider behaviour

Discussion in 'Physics' started by IvanInkoustek, Nov 22, 2022.

  1. IvanInkoustek

    IvanInkoustek

    Joined:
    Apr 27, 2019
    Posts:
    11
    Hello, I have run into some unexpected stuff while using a wheelcollider. I recorded a short clip of what I mean by this. There is no parameter to set the collider size for it's physical interactions, so any time you add a model to the collider, it looks very bad when partially clipping, or even passing through obstacles.

    I was wondering how i would go about fixing this? I want to achieve the suspension gradually adjusting as the wheel rolls onto an obstacle, not to only adjust when the little sphere gets to it.

    clip:
     
  2. Edy

    Edy

    Joined:
    Jun 3, 2010
    Posts:
    2,510
    Fixing that requires Unity to expose the "wheel sweeps" feature of PhysX (the underlying physics engine). The feature has been available in PhysX since 2017 and has been requested periodically in the recent years, but unfortunately Unity devs have little interest and/or low priority for this. There's nothing else we can do about it.

    More information:
    https://forum.unity.com/threads/my-top-three-physics-feature-requests.584263/
     
    Last edited: Nov 23, 2022
    Unifikation and Deleted User like this.
  3. IvanInkoustek

    IvanInkoustek

    Joined:
    Apr 27, 2019
    Posts:
    11
  4. Edy

    Edy

    Joined:
    Jun 3, 2010
    Posts:
    2,510
    I don't think so. This asset implements a solid 3D wheel, which is a different concept. A solid 3D wheel fixes one specific issue at very low speed, but comes with its own set of drawbacks at mid and high speeds (already tried).

    The correct solution for all situations at all speeds is the wheel sweeps feature available in PhysX, but as said it's not exposed in Unity.
     
    Deleted User likes this.
  5. arfish

    arfish

    Joined:
    Jan 28, 2017
    Posts:
    782

    Have you tried to make the obstacles on the ground more naturally shaped? Perhaps it would make the wheels move more naturally over them.
     
  6. Edy

    Edy

    Joined:
    Jun 3, 2010
    Posts:
    2,510
    That wouldn't work either. If you even put round stones, the WheelCollider is still a single raycast so the wheel will penetrate the stone until the raycast hits the shape.
     
  7. arfish

    arfish

    Joined:
    Jan 28, 2017
    Posts:
    782
    But the colliders doesn't necessarily have to match the visible mesh. How about making slope shaped colliders with the same length, or greater than the wheel radius?
     
  8. Edy

    Edy

    Joined:
    Jun 3, 2010
    Posts:
    2,510
    Yes, a possible solution is tweaking the collision geometry, like in this example:

    https://twitter.com/VehiclePhysics/status/1414938217774731264

    However, I've experienced that this one gives better results overall:

    upload_2022-12-29_18-15-27.png

    Both workarounds have the drawback that the wheel will "float" in the air if it is parallel to the curb instead of perpendicular to it.
     
    Last edited: Dec 30, 2022
  9. arfish

    arfish

    Joined:
    Jan 28, 2017
    Posts:
    782
    In some situations maybe using two different colliders would solve these specific edge cases? Then only enable the slope collider when the vehicle is moving towards it at some angle.
     
  10. Edy

    Edy

    Joined:
    Jun 3, 2010
    Posts:
    2,510
    Apart of being a significant work to design, develop and maintain for just that edge case, that workaround might work with a single vehicle in the scene. If you have two or more vehicles, the correct collider for one may not be the correct collider for the other. Also, other physics objects in the scene would be affected if the're close to the curb and the slope collider is enabled or disabled.
     
  11. MrRobinOfficial

    MrRobinOfficial

    Joined:
    Jul 15, 2017
    Posts:
    13
    Btw, I have a question. Can't you just expose the wheel sweeps system by yourself? Since, Unity (dev team) are not likely to make it happen. I assuming you need to understand Unity source code, right? But isn't there any way to implement this ourself? Since PhysX is open source and is just math and code operations, end of the day?
     
  12. Edy

    Edy

    Joined:
    Jun 3, 2010
    Posts:
    2,510
    Nope. PhysX falls in the C++ side of Unity. Anything here must be exposed by Unity explicitly.
     
  13. MrRobinOfficial

    MrRobinOfficial

    Joined:
    Jul 15, 2017
    Posts:
    13
    Bummer, it would be nice if Unity was open source like Unreal.
     
    RichardSim likes this.
  14. THE2FUN

    THE2FUN

    Joined:
    Aug 25, 2015
    Posts:
    63
    Why Unity is very slow in every perspective?