Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

So the web version isn't working because you haven't captured the mouse the way itch likes it. Here's the lines of code from my project that will help. The ready section makes the mouse visible so you can click if the mouse isn't captured. Then in input or unhandled_input you want to do the actual capturing:

func _ready() -> void:

if OS.has_feature("web"):

Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)

else:

Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)

message_timer.timeout.connect(func(): message_label.text = "")


func _unhandled_input(event: InputEvent) -> void:

if OS.has_feature("web") \

and Input.get_mouse_mode() != Input.MOUSE_MODE_CAPTURED \

and event is InputEventMouseButton \

and event.pressed:

Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)

get_viewport().set_input_as_handled()

return