Comments and answers for "Wheel rotation, what am I doing wrong?"
http://answers.unity.com/questions/1851187/wheel-rotation-what-am-i-doing-wrong.html
The latest comments and answers for the question "Wheel rotation, what am I doing wrong?"Comment by CiberX15 on CiberX15's comment
http://answers.unity.com/comments/1851439/view.html
[face palms] Fixed.Wed, 28 Jul 2021 02:57:20 GMTCiberX15Comment by elenzil on elenzil's answer
http://answers.unity.com/comments/1851356/view.html
glad you sorted it.
ps, 360 degrees in a circle, 365 days in a year.Tue, 27 Jul 2021 18:27:39 GMTelenzilAnswer by CiberX15
http://answers.unity.com/answers/1851189/view.html
Ok so the problem was my equation was correctly returning the PERCENTAGE of how far I needed to turn, it wasn't returning the degrees of rotation. So all I had to do to make it work seamlessly is multiply the rotation travel distance by 360. So the corrected code is as follows:
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 * 360, 0, 0);
}
}Tue, 27 Jul 2021 01:18:31 GMTCiberX15