Search Unity

  1. Improved Prefab workflow (includes Nested Prefabs!), 2D isometric Tilemap and more! Get the 2018.3 Beta now.
    Dismiss Notice
  2. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  3. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice
  4. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice

WheelCollider Vehicle substep question

Discussion in 'Physics' started by NDSno1, Sep 14, 2018.

  1. NDSno1

    NDSno1

    Joined:
    Dec 20, 2014
    Posts:
    185
    I would like to ask the detail what vehicle substep of wheelcollider actually is, and how it affects the end result. Is it the number of substep for an Euler integration, order of Runge-Kutta integration, or something else?
    According to @Edy , the higher the number of substep, the less accurate the suspension force calculation becomes. How can this happen? I thought higher number of substep would increase accuracy?
     
  2. Edy

    Edy

    Joined:
    Jun 3, 2010
    Posts:
    1,171
    To be precise, any number of substeps other than 1 causes the reported suspension forces (WheelHit.force) not to match the vehicle's weight by a significant difference.

    This seems a consequence of the (terrible) PhysX 3 vehicle model. I had reported this issue back in March 2014 (Unity 5 alpha) and, long story short, got replied something like "by design - won't fix - you don't understand our model". I wouldn't expect anything to improve here anytime soon.

    Edit: just wanted to emphasize that the issue is at the PhysX side, not Unity's. Unity uses PhysX as it comes from nVidia.
     
    NDSno1 likes this.
  3. NDSno1

    NDSno1

    Joined:
    Dec 20, 2014
    Posts:
    185
    Yeah I'm aware of that after looking around for advice on WheelCollider and got into a bunch of rant threads with frustrated developers, both Unity and Nvidia :). It seems that the original NxWheelShape that WheelCollider based on also has quite a lot of problems with spring simulation, and even friction as well.

    Do the incorrectly reported forces also causes incorrect in other calculations such as tire friction force and sprung mass as well? Because I'm thinking are the "reported" forces different from the actual forces used "internally" for calculation?
    And since low substep causes jittering in angular velocity of the wheel, then using WheelCollider is a trade off between correct spring force or stable velocity? It's a bit strange as I usually heard that higher substep would create more stable and correct calculation.

    I wouldn't either. To be honest I think developers who are serious with vehicle simulation would use their own model or only use WheelCollider as a building block, leaving WheelCollider something for very simple usages such as arcade style driving games with simple physics, or for animating background vehicles even. And even with simple driving physics, struggling with WheelCollider is frustrating enough that having a custom-made arcade physic model is a better choice. So I doubt Nvidia would focus on this aspect of PhysX.
     
  4. Edy

    Edy

    Joined:
    Jun 3, 2010
    Posts:
    1,171
    That's very possible. I can't tell for sure because I stopped trying to research the WheelCollider further after I realized the nonsense of the suspension and the vehicle model.

    It's not a trade off. It's a choice between two options: either having correct suspension forces, or having some sort of smoothing in angular velocity. Even in the later case the jittering is never removed entirely.

    [/advertisement mode on]
    That's how it works in good wheel and tire models that are implemented properly, such as the wheel model in Vehicle Physics Pro. Vehicles in VPP are simulated in a physically correct way even with a single substep. Increasing the number of substeps prevent numerical instabilities in some situations and improve the accuracy of the simulation. The more substeps, the more accurate results. That's not the case in nVidia's vehicle model unfortunately.
    [/advertisement mode off sorry for that]
     
  5. NDSno1

    NDSno1

    Joined:
    Dec 20, 2014
    Posts:
    185
    I was going to use WheelCollider's suspension calculation in my custom vehicle model since they gives fairly OK behavior in very specific cases, but with these negatives, I guess I have to use my own implementation now as I'm expanding my model.
    The friction is, just like you said, utter nonsense, so I ditched it completely right from the start
    Don't worry. I realized the nonsense suspension implementation thanks to your site :). It doesn't simulate actual spring behavior, but rather central around sprung mass and oscillation around a "target position" equilibrium rest length. But the thing about "target position" is that since "target position" = mass*gravity/stiffness, WheelCollider allows for any mass with any stiffness, so I don't really understand how they handle very stiff spring for average mass (same race cars I think have very stiff spring but low mass) and still able to keep that "target".
    I was also choosing between using Euler with substeps or RK4, since quite a few Google results recommend RK4 for spring calculation, but you "personally prefer Euler with substeps" so I think I might start there. However, implementing substeps into Unity's fixed update is something I still need to do more research into.