Here's your problem (unless the indentation was messed up by your copy-and-paste):
func _input(event):
if event is InputEventMouseMotion:
$Head.rotate_y(deg2rad(event.relative.x * mouseSensitivity))
var change = event.relative.y * mouseSensitivity
if change + cameraAngle < 90 and change + cameraAngle > -90:
$Head/Camera.rotate_x(deg2rad(change))
cameraAngle += change
You're testing for InputEventMouseMotion
, but only applying it to the rotation of the head. The line setting change
is run for every input, regardless of type. You probably want to place the rest of the code under the if
as well.
Note: In future, when posting code, please format it correctly so that it is readable. This means either placing 4 spaces in front of all lines or, as a shortcut, clicking the "Code Sample" formatting button (it looks like two curly brackets: {}
).