I am writing my own car script,i am having a problem with euler angles of the wheel.I set tire’s local euler angle to a floating value but it keeps rotating rather than staying at that angle.I want to set the z axis of the tire lets say to 30 degree,i write this code;
backLeftWheel.localEulerAngles.z = 30;
But it works like i used transform.Rotate it keeps rotating?? I don’t understand why.Help me pls.
Does the wheel also rotate in the X axis as it rolls? If so, I would nest it under an empty GameObject and use that parent object to perform the Z rotation, leaving the X rotation to the child object which can also own the mesh renderer.
Otherwise, this would have worked better if the Z rotation was along the axis of the wheel and the Y axis was (initially) straight up - due to the order in which Euler rotations are applied.
It is simplest of all, though, to use an extra parent GameObject, and only use one axis of rotation in each GameObject, so that you get full control over the order in which the rotations apply.