Help maintaining angle of camera as body rotates

Godot Version

4.2.2

Question

I’m building a first person shooter (ish), where the main mechanic involves changing the player’s gravity to have wherever their mouse is pointing be down. Part of how I do that involves rotating the player body so that the controls map properly. But right now, the camera also suddenly rotates. I need a way to get the camera to maintain it’s “absolute angle”, so that they’re now looking “down”, while the relative angle changes so that the player’s “straight ahead” is still a camera rotation of (0,0,0). I’ve tried simply counter-rotating the camera, but that causes problems with x rotation vs z rotation. (All of the rotation I’m doing is purely X and Y, and If possible I’d like it to stay that way)

Would you mind sharing a short video of the problem you’re facing? You can use https://streamable.com/ for that.
Also, share any relevant code by using preformatted text with backticks ``` on both start and end of the snippet.
This will help better understand the issue, as 3D rotations are usually not intuitive for humans.

1 Like

It sounds like gimbal lock, which can be solved like this. Yours is a weird variant, and likely your problem would be solved by making the Camera3D completely separate from the Player itself and then applying transforms to the camera and its mounts.

I also second what @wchc said. Without more information from you, we really can’t help you with much more than guesses.

1 Like