![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | Luckytu |
I want to export my first person game for html5. All my keyboard inputs work in a webbrowser, however the mouse inputs don’t. I want to rotate the player / camera using the mouse. What would be the proper way to get mouse inputs to work?
My code is:
func _input(event: InputEvent) -> void:
if event is InputEventMouseMotion and Input.get_mouse_mode() == Input.MOUSE_MODE_CAPTURED:
head.rotate_x(deg2rad(event.relative.y * mouse_sensitivity * -1))
self.rotate_y(deg2rad(event.relative.x * mouse_sensitivity * -1))
var camera_rot = head.rotation_degrees
camera_rot.x = clamp(camera_rot.x, -89.9, 89.9)
head.rotation_degrees = camera_rot
head being the node the camera is a child of.
Mouse mode is set to
Input.MOUSE_MODE_CAPTURED
The script is attached to a KinematicBody (the player).
It works for windows export but not in html5.