Hello!
I've been trying to make a first person camera.

``````var camera = get_node("Camera");
var plus_pitch = SENSITIVITY * mouse.relative_y;
var plus_yaw = fmod(SENSITIVITY * mouse.relative_x,360);
``````

This works correctly, I can watch around freely. However the problem arises when I try to limit the camera like so:

``````plus_pitch = min(plus_pitch, 45 - pitch);
plus_pitch = max(plus_pitch, -45 - pitch);
``````

The problem comes from the fact that apparently, plus_pitch is a negative value. Yet, when I use it with rotate, it causes a positive rotation. Why is this so?
For now, I've just switched its sign to do calculations:

``````plus_pitch *= -1;
plus_pitch = min(plus_pitch, 45 - pitch);
plus_pitch = max(plus_pitch, -45 - pitch);
plus_pitch *= -1;
``````

This effectively limits the camera to a 90° degree angle, but it causes another problem: if i rotate my camera around (to the left and to the right) it starts spinning for no reason at all, as if I was the yaw actually influenced the pitch. I used global_rotate instead of rotate when using the yaw to be sure I didn't rotate the camera in its space, but rather in world space, so I'm not sure what the problem could be.

TL;DR why does a negative angle cause a positive rotation in rotate()?
why does global_rotate() seem to affect the pitch instead of being, well, global?

in Engine

I'm not 100% sure I understand the question but I have a strong feeling that your problems might be a result from a fact that by default camera is facing a negative z axis (while I'm assuming you were writing this for positive z).