Godot Version
4.2.2
Question
so currently I am making a first person game and I am really new to godot and I am trying to make it so when you use your mouse you can look around. I have been following this tutorial but it is kinda old and has some missing parts of it. I am trying to make the looking around system and I am getting some errors. I am getting a error in my stack trace it says “Invalid get index ‘relative’ (on base: 'InputEventMouseButton)” I have no clue what to do for this here is my code.
Camera movement using mouse capture
@onready var Neck := $Neck
@onready var Camera := $Neck/Camera3D
func _unhandled_input(event: InputEvent):
if event is InputEventMouseButton:
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
elif event.is_action_pressed(“ui_cancel”):
Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
if Input.get_mouse_mode() == Input.MOUSE_MODE_CAPTURED:
Neck.rotate_y(-event.relative.x * 0.01)
Camera.rotate_x(-event.relative.y * 0.01)