Hi guys! I’ve run into a problem while calculating how the steering rack affects the car body position. I need to achieve a steering-rack effect similar to Assetto Corsa.
I’m using a RayCast wheel setup attached to a RigidBody, and I need to transfer the reverse impulse from the steering rack back to the car body. I wrote the following code:
Perhaps some of you have worked on AAA-grade racing physics how is this effect usually implemented? Am I calculating the transfer of impulse to the car body correctly? It produces a certain effect, but it doesn’t look as realistic as in Assetto Corsa, BeamNG.
private void CalcSteeringRackForce(Vector3 oldWheelPosition, Rigidbody rb)
{
if (wheel == null || wheel.vehicleBody == null) return;
if (!wheel.isGrounded) return;
Vector3 wheelDisplacement = transform.position - oldWheelPosition;
Vector3 localDisp = rb.transform.InverseTransformDirection(wheelDisplacement);
float lateralDisp = localDisp.x;
float forceX = -lateralDisp * rackForceMultiplier;
Vector3 localForce = new Vector3(forceX, 0f, 0f);
Vector3 worldForce = rb.transform.TransformDirection(localForce);
rb.AddForceAtPosition(worldForce, transform.position, ForceMode.Force);
lastWheelPosition = transform.position;
}