- Home /
Cannot Rotate Player after Matching Camera Rotation?
Hello All!
I'm making a 2.5d game similar to games like Octopath Traveler, Paper Mario, Klonoa, Tomba, etc...
The player should only only ever be looking left or right.
I've accomplished this using the following and it was working fine for me.
// Get Input from the player
myVector.x = Input.GetAxisRaw("Horizontal");
// Flip the player based on input
if ((myVector.x < 0 && facingRight) || (myVector.x > 0 && !facingRight))
{
facingRight = !facingRight;
transform.Rotate(new Vector3(0, 180, 0));
}
myController.Move(myVector);
However, I needed to incorporate different camera rotations.
I added the following code before "myController.Move" to adjust the characters movement based on the camera angle:
Quaternion inputRotation = Quaternion.Euler(0, mainCam.transform.eulerAngles.y, 0);
myVector = inputRotation * myVector;
Adding this worked to fix the players movement and it now moves the player based on the camera rotation.
However, the problem I now have is the player's game object cannot be rotated anymore. I.e. the player will only look left even when they need to turn around due to moving right. I can't even manually rotate them in the inspector anymore...
Is anyone able to assist with this? Any help or guidance would be immensely appreciated!
Your answer
![](https://koobas.hobune.stream/wayback/20220613052854im_/https://answers.unity.com/themes/thub/images/avi.jpg)