Player Can't Rotate 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 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 moving to the right.

Is anyone able to assist with this? Any help or guidance would be immensely appreciated!

Bump? :hushed:

The trick is in having the correct hierarchy of what turns exactly 180 degrees left /right to go left and right, and what just merely “looks around” as the camera follows the contour of the room.

Here was my take, full source links in comments to video.

https://www.youtube.com/watch?v=BtT1N1lzFns