Help! I’m using c# on unity and my problem is that no matter which way I face I always go in the same direction. I included a picture of my code and a video of my glitch in action. I’m sorry I can’t put a video of the glitch.

The object “transform” only refers to the object the script is directly attached to. You set up a reference to the player’s body with playerBody, and you’re not using it. You’re only setting the camera’s x and y rotations with “transform.LocalRotation = Quaternion.Euler(xRotation, yRotation, 0f);” What you need to replace that with is something like:

“transform.LocalRotation = Quaternion.Euler(xRotation, 0f, 0f);
playerBody.LocalRotation = Quaternion.Euler(0f, yRotation, 0f);”

Source link