So, I made a simple First Person Camera script for my game, and the way it's supposed to work is the camera is rotated by localEulerAngles to rotate the camera around, and then just the Y-axis rotation is also applied to the character, so that he moves in the direction of the camera.
This isn't how its working now.
I've narrowed down the two most likely problems in the scripts, and this first one is from the camera controller:
player.transform.localEulerAngles = new Vector3(0, rotationX, 0);
cam.transform.localEulerAngles = new Vector3(-rotationY, rotationX, 0);
Note: the camera works just fine, and rotates perfectly in all directions.
Secondly, the player movement controller, which might not be actually be moving locally? I can't tell.
transform.Translate (new Vector3(0, 0, Input.GetAxis("Vertical") * walkSpeed));
transform.Translate (new Vector3(Input.GetAxis("Horizontal") * strafeSpeed, 0, 0));
There you go. Right now, even though the camera moves just fine with the mouse, and, incidentally, the whole script used to work, the player moves forward on the global Z-axis with W
and backwards with S
, all the while acting like a shooter on rails.
Thank you!