incompatible camera rotating and press any key. Error: Invalid get index relative (on base: "InputEventKey")

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By ManiCus

I use that for rotating the camera of the player:
if event is InputEventMouseMotion and Input.get_mouse_mode() == Input.MOUSE_MODE_CAPTURED:
rotate_y(-event.relative.x * mouse_sensitivity)
var change = -event.relative.y * mouse_sensitivity_y
if change + camera_angle < 90 and change + camera_angle > -90:
$Cos/cos.rotate_z(deg2rad(change))
camera_angle += change

but when i try to move the position of the player with the asigned keys (or i press any key)
i have a problem with:
rotate_y(-event.relative.x * mouse_sensitivity)
in concret the relative error name: Invalid get index relative (on base: “InputEventKey”)

i don’t know if someone knows what is happening but if you can’t help my I will be so gratefull :slight_smile:

:bust_in_silhouette: Reply From: Ertain

The variable event in the code you posted doesn’t have the property “relative”. It may have to do with the code checking for whether event is an object of InputEventMouseMotion. From what I can tell, event is an object of InputEventKey (though I can’t really pinpoint where because I can’t easily read the above code).