Ok so I am trying to get a wheel to rotate an object as if it is a wheel of a known diameter and traveling a known distance, and I need to know how much to rotate the object.
My understanding is the equation for that is ( distance / circumference = degrees to rotate ), where circumference = diameter * pi. Except when I try to actually apply that equation the rotations I am getting are tiny compared to the movement.
public class WheelDebug : MonoBehaviour
{
public float MoveSpeed = 1;
public float Diamiter = 1.41f;
// Update is called once per frame
void Update()
{
float distanceMoved = MoveSpeed * Time.deltaTime;
transform.position += Vector3.forward * distanceMoved;
float circumference = Diamiter * Mathf.PI;
float rotationToTravelDistance = distanceMoved / circumference;
transform.rotation *= Quaternion.Euler(rotationToTravelDistance, 0, 0);
}
}
So based on my understanding, what is happening above is every frame, which occurs ~60 times a second, my object moves MoveSpeed * Time.deltaTime, resulting in the object moving 1 unity unit or meter, per second in game, regardless of framerate.
Since I record it as distanceMoved, I can then plug that into the wheel turn calculation since I know that is the exact distance the object moved this frame, and… I know what I did wrong.
Posting this anyway so anyone running into the same problem