I've got a coroutine that I'm calling to rotate and object so that it faces another direction using Quaternion.Slerp. It doesn't seem to be rotating correctly however:
public IEnumerator QuatRotate(float _rotateSpeed)
{
float rate = 1.0F / _rotateSpeed;
float timeScale = 0.0F;
while(timeScale < 1.0F)
{
timeScale += Time.deltaTime * rate;
transform.rotation = Quaternion.Slerp(transform.rotation, Quaternion.Euler(0F,180F,0F), timeScale);
print(timeScale);
yield return null;
}
}
I'm printing out timeScale to the console and I can see that it's incrementing upwards to a value of 1.0F as it should, but the slerp function seems to be ignoring this and rotating at a different rate, even though I set timeScale as its `t` parameter. I get how Unity's Lerp functions work, using 0..1 as relative distance between the first two parameters, but it doesn't make sense when I see timeScale incrementing linearly while the object rotates either too fast or too slow.
↧