Can anyone help explain to me why this is not rotating forward and back by two degrees?
I have the following ienumerator which is supposed to open the jaw on a character, I don’t want to animate it because it’s part of a lip sync script.
IEnumerator OpenJaw(float amount, float speed){
float start = jawbone.eulerAngles.z;
float end = jawbone.eulerAngles.z + amount;
float weight = 0f;
float startTime = Time.time;
Debug.Log("Amount is " + amount);
Debug.Log("Original rotation is " + start);
Debug.Log("Target rotation is " + end);
while (Time.time - startTime < speed) {
weight = Mathf.Lerp (start, end, (Time.time - startTime) / speed);
jawbone.Rotate(0,0,weight);
yield return null;
}
}
It spins all the way around instead of just moving as expected, the readout is as follows.
When going down:
Amount is -2.1
Original rotation is 176.8024
Target rotation is 174.7023
When going up:
Amount is 2.1
Original rotation is 213.8699
Target rotation is 215.9699