Help with my first person game

Godot Version



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:
elif event.is_action_pressed(“ui_cancel”):
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)

Relative property only appears on inputeventmousemotion

How should I implement that into my code I have no clue where to place that.

it’s hard to tell what your code is doing because the indentation has been formatted out. Next time paste it after three ticks (the `~ key)

paste here

Anyways it means you need to make sure the even is mouse motion before trying to get .relative

func _unhandled_input(event: InputEvent) -> void:
    # etc...
    if event is InputEventMouseMotion:
        Neck.rotate_y(-event.relative.x * 0.01)
        Camera.rotate_x(-event.relative.y * 0.01)

Ohhh thank you so much this makes more sense and I will do (the '~ key) nex time