So I’m having an issue where slerping to this value results in it hanging at ~0.001 and it never resolves its state… Am I making any glaring mistakes?
private void SetRotationManually()
{
_targetRotation = Quaternion.Euler(tra nsform.eulerAngles.x,Mathf.Round(transform.eulerAngles.y*-1),transform.eulerAngles.z);
}
private bool CheckTurn()
{
ChangeWindState(WindStates.Dead);
if((int)Mathf.Round(transform.rotation.eulerAngles.y) != (int)_targetRotation.eulerAngles.y)
{
float t = Time.deltaTime*_turnTime;
transform.rotation = Quaternion.Slerp(transform.rotation,_targetRotation,t);
return true;
}
else
{
_targetRotation = new Quaternion();
ChangeState(PlayerStates.Walking);
return false;
}
}
youre storing float t in a local variable. Try moving it to a member variable. t is never reaching 1.0 for your slerp. Take a look at the Slerp reference, and more specifically the time paramter(the Quaternion Slerp doesnt explain the time parameter, here is the link to vector slerp, I believe they work the same way):
http://docs.unity3d.com/Documentation/ScriptReference/Vector3.Slerp.html
Thanks! This actually helped, with the conditional checks from Mathf.Approximately!