When you say it doesn’t work, do you mean that the game errors, or that the game doesn’t error but nothing happens, or that something happens but it’s not the expected result?
Since you asked for feedback on your code, I recommend:
# Don't use magic numbers. This avoids that.
const MINIMUM_ROTATION = -60.0
const MAXIMUM_ROTATION = 90.0
# Export your mouse sensitivity values so you can play with
# them, and later allow your player to set them. Also, best
# practice is to use full, descriptive names for variables.
# Typically people want a slower speed vertically, and a
# faster one horizontally.
@export var mouse_sensitivity_x: float = 0.075 #or whatever you set it at
@export var mouse_sensitivity_y: float = 0.075 #or whatever you set it at
# Adding explicit types to your arguments and return values
# will save you headaches down the road.
func _input(event: InputEvent) -> void:
if event is InputEventMouseMotion:
head.rotate_y(-event.relative.x * mouse_sensitivity_x)
camera.rotate_x(-event.relative.y * mouse_sensitivity_y)
camera.rotation.x = clamp(camera.rotation.x, deg_to_rad(MINIMUM_ROTATION), deg_to_rad(MAXIMUM_ROTATION))
Also, on what @normalized said: The problem was not with your code or the new version. Something in your game is eating the inputs before they get to _unhandled_input(). Keep that in mind for the next time you have an input that isn’t working the way you think it should.