Camera not rotating as intended

For some weird reason, the camera snaps back in place regardless of where I move my mouse.

input function

    public override void _Input(InputEvent @event)
    {
		float maxRot = 90f; 
		Vector3 rot = cam.Rotation;

		if (interfaceMode == false && @event is InputEventMouseMotion eventMouseMotion)
		{
			rot.X = Mathf.Clamp(eventMouseMotion.Relative.Y * sensitivity, maxRot * -1, maxRot);
			rot.Y = eventMouseMotion.Relative.X * sensitivity;
		}
		GD.Print(rot);
		cam.Rotation = rot;
    }

and here’s the output;

and the sensitivity is 0.001, if that matters at all.

Looking for fixes.

Angles are in radians, so maxRot should be PI * 0.5; I assume you’re trying to limit to +/- 90 degrees.

Thanks, but the problem isn’t that, otherwise it’d simply just limit it to 90 rad (a lot of rotation, meaning it effectively doesn’t limit) and in the Y it still snaps, so it’s not that.

You’re setting the rotation components to the mouse values. You should be adding the mouse values to the rotation components.

So, you helped me with two issues that I hadn’t even anticipated.
This input function is a part of a larger movement script, so I overwrote the rotation of the camera with the physics process, So I commented out the physics process and lo and behold, the camera movement works.

Thank you for your feedback.

1 Like