I’m trying to rotate a tire on a vehicle. This is a parent object to other object containing the wheel so that I can rotate the wheels around in a circular motion then also be able to rotate the wheels side to side for turning. I can rotate the wheels just fine in the editor (and in the script for the circular rotation) but I can’t seem to make is rotate correctly side to side in the script.
Before shot:
and after shot (again rotated using the editor - notice the z rotation):
I’ve tried a number of different ways but I can’t get the script to rotate it properly.
if(Input.GetKey( KeyCode.R ) )
{
float step = 2f * Time.deltaTime;
frontLeft.rotation = Quaternion.RotateTowards(frontLeft.rotation, new Quaternion(frontLeft.rotation.x,frontLeft.rotation.y ,frontLeft.rotation.z+.2f,1f) , step);
frontRight.rotation = Quaternion.RotateTowards(transform.rotation, new Quaternion(transform.rotation.x,transform.rotation.y,transform.rotation.z+.2f,1f) , step);
}
Thanks for any help anyone can offer.