- Home /
problem after rotate an object
hello guys, what i actually have is this
private IEnumerator Rotate(
float in_deltatime,
int id,
float duration,
EInputState in_secondState)
{
Vector3 rot = _players[id].transform.rotation.eulerAngles;
float endRotation = rot.x + 360.0f;
float t = 0.0f;
while ( t < duration )
{
if ( _stopRotation[id] == true )
{
yield break;
}
t += in_deltatime / duration;
float angle = Mathf.Lerp(rot.x,endRotation,t);
Vector3 fixedRot = new Vector3 (-angle,rot.y,rot.z );
_players[id].transform.rotation = Quaternion.Euler( fixedRot );
yield return null;
}
}
after it complete a 360 degrees rotation will return to -180, but sometimes is stopping firstly to -180, but sometimes is going to jumpt from -180 to something like 140 degrees.. everything after the while loop... how i can should fix fix it? any idea?
Comment