Basically I want to create a suspension that has 2 springs with 2 seprate compressions, one spring is actually for the tire.
I am keeping things simple, so its only the vertical action(raycast for example)
As far as I know and wich works quite well, is this method:
- create a raycast with a length of:
rayLength = suspensionTravel + radius; // (so it's basically something like 0.2 + 0.3 = 0.5) rayHit = CreateRay(rayLength,suspensionPosition);
- calculate the compression like this:
prevCompression = compression; compression = (suspensionTravel - (rayHit.distance - radius));
- calculate vertical force like this:
springVelocity = (compression - prevCompression)/timeStep; springForce = springRate * compression; // springRate is something like 50000 damperForce = damperRate * springVelocity; // damperRate is something like 2500 totalSpringForce = springForce + damperForce;
Now I'd like to know how I'd add a secondary spring to the same raycast?
The difficult part for me, is to know how to calculate the secondary compression(tire deflection in this case) ?
And how to combine these 2 compressions, so that they would have theyr seprate functionality?
Thanks in advice!