Camera rotation affects player's direction while moving

Godot Version

Godot 4.3 android editor

Question

Am having issues preventing my camera rotation from changing my player movements direction, when ever i my player is moving in a particular direction and i try to rotate my camera it affects my player direction, i want to be able to rotate my camera around my player while moving without the a change in direction. Currently i can rotate my camera around my player when player is idle without a change in direction with a simple code:

visual.rotate_y(deg_to_rad(event.relative.x * sens_horizontal))

where the variable “visual” represents my character 3d-models node, the code above help keep it in play while rotating the camera when idle, i tried using similar methods for moving but it failed horribly. Please i really need help with this, it been month’s since i was stuck with this

I believe it would help if we could get some more information on the problem. Specifically, what does the code for the player/camera look like? If you could post them, it’d be a massive benefit to my own understanding.

If possible, could you also post a screen-recording? I don’t know what OS you’re on, but Windows comes with Snipping Tool that can record screen-captures, and Mac comes with Screenshot and QuickTime Player. I’m mainly asking for the screen recording, because I’m not sure what the camera’s doing wrong. A visual would be a great help.

2 Likes


This is the line of code that ensure that my player 3d model doesn’t rotate along with my camera when even my player is idle. I couldn’t upload a video because this website keep saying new user can’t upload media.

My point here is my player 3d model rotates horizontally with my camera whenever am moving my player. It not an engine issue (i use the godot 4.3 mobile editor) but i don’t know what code i might be missing here because I have tried for months

Do you want to prevent camera from its rotation? Even if player rotates in other direction?

Then just set the rotation of the camera to the " - " negative rotation of player.

Yeah i want to rotate my camera without my player rotating along with it while moving?? The issue here is i want to rotate my camera around my player when player is running without the camera rotation changing the player direction of movement (making it impossible to rotate the camera around player while moving)

I can’t say I completely understand what you’re meaning still, but I’ll try to restate what I think the problem might be, and you tell me where I’m wrong:

You’re pressing a button (I’m not sure what your control scheme is) to move your third-person character forward, and you are swiping on the screen to change the direction the camera is looking at your player, but instead of just swivelling the camera around the player, it changes the direction the player is moving.

Is that right? Because it doesn’t feel right. It would feel odd to me if that wasn’t the expected behavior. A lot of third-person shooters I’ve played bind the player’s forward direction with the direction of the camera, with a few exceptions to maintain predictable behavior.

Perhaps, I’m missing something. Is the player’s direction of movement supposed to be locked? In other words, are they supposed to move in a straight line without turning? Because that would explain a lot for me.

If I’m wrong, I don’t know what I need in order to understand the problem better. Since you can’t post videos, it’s hard for me to visualize.

In any case, here’s a tutorial on third-person controllers by Lukky that I’ve found to be of tremendous help to my projects. It has a lot of information on setting up a third-person character in general, but you can jump ahead to the camera parts if you wish. If nothing else, maybe it will help move you in the right direction.