I’ve got a problem…
I’m trying to rotate the wheels of a car according to the Rotations per minute of the wheelcollider that they are supposed to represent visually…
the wheel-mesh is a child of the wheel-collider and has this simple script on it:
function Update () {
transform.localEulerAngles.y = transform.parent.collider.steerAngle;
transform.localEulerAngles.x += transform.parent.collider.rpm * 0.01666 * 360 * Time.deltaTime;
}
The problem is that whatever I do the rotation gets stuck at 90 degrees in one direction and at 270 degrees in the other.
the weird thing is that this only happens for transform.localEulerAngles.x, if I use transform.localEulerAngles.z it rotates around and around and around without a problem.
The first car I made had wheels with a different local axis and there I used z and everything was fine…
A little demonstration of the problem:
http://gamegui.net/temp/vehicle_box_problem.html
Give a little gas to spin the wheel and notice how it gets stuck. then press space and see how everything works just perfect when it’s spinning around z… Is this a bug? what can I do?
I spent the whole evening trying to figure out what is wrong… any help would be greatly appreciated!