Invalid get index 'relative' (on base: 'InputEventMouseButton').

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By ragacakaci
func _input(event):
	if is_network_master():
		if event is InputEventMouseMotion:
			head.rotate_x(deg2rad(event.relative.y * MOUSE_SENSITIVITY * -1))
		head.rotation_degrees.x = clamp(head.rotation_degrees.x, -43, 40)
		self.rotate_y(deg2rad(event.relative.x * MOUSE_SENSITIVITY * -1))
                                                       problme here

making 3d sword game mulitplayer

when i host it and i move or attack its shows this problem

Edited the OP to fix code formatting…

jgodfrey | 2023-01-07 15:29

:bust_in_silhouette: Reply From: jgodfrey

It looks like you need to indent those last 2 lines to be part of the if event is InputEventMouseMotion: block. Otherwise, non-mouse-related events will fall through those last two lines, and can cause an error like you’re reporting…

So, you probably want this:

func _input(event):
    if is_network_master():
        if event is InputEventMouseMotion:
            head.rotate_x(deg2rad(event.relative.y * MOUSE_SENSITIVITY * -1))
            head.rotation_degrees.x = clamp(head.rotation_degrees.x, -43, 40)
            self.rotate_y(deg2rad(event.relative.x * MOUSE_SENSITIVITY * -1))