- Home /
Custom Wheel Collider Suspension
I am trying to make a Custom WheelCollider but i have a few problems.
float SuspensionForce = SuspensionSpring * (m_suspensionCompression + m_suspensionCompressionPrev) / 2 + SuspensionDamper * (m_suspensionCompression - m_suspensionCompressionPrev) / Time.fixedDeltaTime;
Damper cause vibration, High damping = High Vibration
System never getting stable
Is there a way to limit max compression?
Is there a way to sleep rigidbody when its stable? As i know, applying force will wake it up.
Help! What should i do for a realistic Wheel?
m_suspensionCompression unit: meters
SpringForce = SpringCoefficient * compressiondistance;
DampingForce = DampingCoefficient * compressionspeed;
Currently compression calculating form raycast hitpoint.
Answer by HappyMoo · Jan 23, 2014 at 05:18 AM
The DampingForce is supposed to act against the Suspension force. Have you checked that they don't have the same sign and add up? Is your SuspensionDamper negative?
Also if that Damping doesn't work out, you could simulate one step further, meaning calculating a speed from the force and then simply implement the damping by doing something like this:
damp=0.99;
speed = damp*speed;
Also, have you checked the new new Sample Assets? It includes a car and maybe they implemented some kind of suspension as well:
currently my formula act like a damper, if compression increases, add force into spring force if compression decreases, removes force from spring force i checked sample asset but it is using normal wheel collider.
For my formula problem starting when spring force near stable. Because: Lets say Sforce + Dforce = stableforce>>next frame>>Dforce = 0 so body drops down, compression increases>>it generate Dforce, now our Sforce + Dforce > stableforce >>compression decreases>>Sforce + Dforce < stableforce, This loop continue and this occurs vibration.
i think i shouldn't take compression from raycast. Because in this system, Wheel always in contact with ground. But in real life, sometimes its loseses contract for a short time. And maybe this can change vibration effect.
Anyway, can i find normal wheelcollider source?.
Have you checked the wikipedia article about damping, especially the system behaviour part?
http://en.wikipedia.org/wiki/Damping
I just skimmed it for now, but wiwth those formulas, you may be able to find good constants for your spring and dampers. Also, keep in $$anonymous$$d that the values are always only valid for one type of car and it needs adjustment if you change car mass etc. You surely thought about that, but I mention it still, because you may not test your suspension under realistic conditions - like if you don't really put the full cars weight into it, they might act differently than on the car