Abacab
1
Hello!
I have problem with my wheel rotation. It works if I just make them rotate or if I just make them turn, but not both at the same time! What am I doing wrong?
public Transform wheelFLTrans;
public Transform wheelFRTrans;
public Transform wheelBLTrans;
public Transform wheelBRTrans;
void FixedUpdate ()
{
// Wheel rotation
wheelFLTrans.Rotate (wheelFL.rpm / 60 * 360 * Time.deltaTime, 0, 0);
wheelFRTrans.Rotate (wheelFR.rpm / 60 * 360 * Time.deltaTime, 0, 0);
wheelBLTrans.Rotate (wheelBL.rpm / 60 * 360 * Time.deltaTime, 0, 0);
wheelBRTrans.Rotate (wheelBR.rpm / 60 * 360 * Time.deltaTime, 0, 0);
// Steering rotation
wheelFLTrans.localEulerAngles = new Vector3 (0, wheelFL.steerAngle * 2, 0);
wheelFRTrans.localEulerAngles = new Vector3 (0, wheelFR.steerAngle * 2, 0);
}
Its because you are setting the steering rotation directly. Basically ona simple level you are doing this:
float x = 1;
x *= 5;
x = 3;
Its the localEurlerAngles that is your culprit here. To fix change it rotate as your other lines do and convert your steer angle from degress to Radians (Mathf.DegtoRad)