# Movement Issues

I am working on a stealth game. Currently I am making a coroutine that allows the player to peek around corners while in cover. I am having a small problem though. The code gets to the snippet below with no issue, but when it hits the rotation part, it does a few odd things. If I rotate the player hit box by 30f * Time.deltaTime, it rotates the wrong direction into the wall and flips out, crashing the game. If I rotate the player hit box by 30, it rotates the correct way but it jumps to 30 degrees of rotation then jumps to 60 degrees, 90, etc and continues spinning. Other times, the rotation just does crazy things that I can’t replicate. I’m not sure if I am missing something huge or just don’t understand how some aspect or another works. Any help would be great. Thanks!

``````while(canPeek == true && count <= 30)
{
count++;
yield return null;
Debug.Log(rotDir + count);
}
if(count >= 30)
transform.Rotate(30f * Time.deltaTime, 0f, 0f);
while(canPeek == true && count >= 30)
{
if(Input.GetKeyDown("left ctrl"))
{
//switch cover to second closest
}
Debug.Log(rotDir + count);
yield return null;
}
if(count >= 30)
transform.Rotate(-30f * Time.deltaTime, 0f, 0f);
``````

Hi,
The line `transform.Rotate(-30f * Time.deltaTime, 0f, 0f);` works perfect .try adding this line to an cube and check.there might be another script that is acting on the same object.Also you are rotating the object twice at line 8 and line 19 with the same if condition with opposite direction.You are supplying a rotation values in x direction and immediately you are supplying counter rotation value(in negative) in x direction which actually does not move your object at all.
There are many ways that you can use to rotate the object like lerp angle,slerp or using euler angles.