Mouse jumps on exported web build

Godot Version

4.2.1

Question

When walking around the scene, sometimes the game drops a frame, during which the camera rotation snaps to wild angles. (Exported web build on itch.io).
I haven’t found any fixes on the web, so I’ve been trying to fix it with clamping the mouse input and some performance optimizations, but is there a proper way to do it?

@export var mouse_sensitivity = 1.2
@onready var camera = $Camera3D

func _unhandled_input(event):
	if event is InputEventMouseMotion:
		var mouse_input = event.relative * (get_window().get_size().y * mouse_sensitivity * 0.000001) # Multiply mouse input by sensitivity and vertical resolution to make it independent of the window size 
		if mouse_input.length() <= 0.5: # If the mouse moves too far, ignore input
			rotate_y(-mouse_input.x) # Horizontal rotation
			camera.rotate_x(-mouse_input.y) # Vertical rotation
			camera.rotation.x = clamp(camera.rotation.x, -0.5 * PI, 0.5 * PI) # Clamp camera angle
		else:
			print("Mouse snap detected!   ", mouse_input)

Here’s a video showing what I mean, as I can’t upload files directly yet:

Possibly you could try to investigate Input.use_accumulated_input.

1 Like

Thank you, I tried that but couldn’t get it working on the web export - it was still accumulating :s. Big difference in the editor though.
I was following below guide but it didn’t seem to improve anything: