0 votes

I found that when I export my game to HTML5 and play in Firefox, if the player captures the mouse, then using func _input(event): and event.relative to detect mouse motion isn't reliable and it sometimes (often) registers horizontal movement even when the mouse is still. It doesn't give that strange effect in Firefox if the mouse is not captured, and it doesn't do that in Chrome or Edge either when the mouse is captured or when it's not captured, and it only does that in Firefox when the mouse is captured AND the browser zoom is exactly 100%. Changing the browser zoom to 90% or 110% corrects it, and I previously published a game that used mouse capture that was working fine in Firefox in late 2021 but is now showing that same behavior even though I haven't done anything to the game so it's very weird and makes me think it might be the result of a Firefox update messing things up instead of a Godot issue, or might just be something weird with my computer.

I made a minimal test build and uploaded to https://www.newgrounds.com/portal/view/project/1811360
so if anyone could let me know if you also see the same behavior - motion on the x-axis registering when the mouse is captured and not moving in Firefox at normal 100% zoom but not in other browsers or when the mouse is not captured - then I'll report it as an issue on the Godot GitHub. Otherwise I'll assume it's just an issue with my own computer. The source code for the project is

extends Control

var latest_x
var latest_y
onready var label_node = get_node("Label")

func _physics_process(delta):
    label_node.text = "Mouse motion x: " + str(latest_x) + ", y: " + str(latest_y)
    latest_x = 0
    latest_y = 0

func _input(event):
    if event is InputEventMouseMotion:
        latest_x = event.relative.x
        latest_y = event.relative.y
    if event is InputEventMouseButton:
        if event.pressed and (event.button_index == BUTTON_LEFT):
            Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
        if event.pressed and (event.button_index == BUTTON_RIGHT):
            Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
Godot version 3.4 stable
in Engine by (29 points)
edited by

Using Firefox 95.0.2-1 (64-bit) on Arch Linux, I cannot reproduce the bug.

I am not seeing that effect; when I move the mouse it sometimes detect the movement. When the mouse is captured, and I don't move the mouse, there doesn't seem to be any input detected (as expected in the engine). I'm using FF 95.0.1 on Linux Mint, BTW.

Sounds like it's probably just an issue with my computer (using Firefox 95.0.2 64-bit on Windows)... thanks for pointing me in the right direction.

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.