I have been having some trouble with rotating my sprite and moving it forward.
if (Input.GetKey (leftKey)) {
transform.Rotate (new Vector3(0, 0, speed));
}
if (Input.GetKey (rightKey)) {
transform.Rotate(new Vector3(0, 0, -speed));
}
if (Input.GetKey (forwardKey)) {
transform.Translate (transform.up*Time.deltaTime);
}
if (Input.GetKey (reverseKey)) {
transform.Translate (-transform.up*Time.deltaTime);
}
As you can see, I rotate the object with left and right keys, then try to move the object forward when the forward button is pressed.
For some reason, when turning and going forward, it moves down when it should be facing 90 degrees, moves up when it should be facing 180 degrees, and moves down again when facing 270 degrees.
Is there some sort of error in the rotation code?