Lock rotation when moving so object only rotates once

Hi, I have the following script for my movement, however when I move the object spins (for obvious reasons).

How can I prevent if from rotating more than once in any one given direction?

            if (Input.GetKey(playerControls.playerOneControlRight))
            {
                transform.position += new Vector3(0.035f * playerAttributes.playerOneBaseMoveSpeed, 0, 0) * Time.deltaTime;
                transform.Rotate(new Vector3(0, 180, 0)); 
            }

            if (Input.GetKey(playerControls.playerOneControlLeft))
            {
                transform.position -= new Vector3(0.035f * playerAttributes.playerOneBaseMoveSpeed, 0, 0) * Time.deltaTime;
                transform.Rotate(new Vector3(0, 180, 0)); 
            }

Many thanks in advance :slight_smile:

You can, for example, store this information as a boolean. You can initialize it to false, then only rotate left when its false and immediately set it to true. And rotate right when its true and set it to false.

that worked a treat, thanks!