0 votes

I want to move a camera using the mouse (laptop touchpad), but the function to detect mouse movement does not work when I also press any key.

Do you know how to fix this or any alternate function to detect mouse movement ?

Here is the script:

func _input(event):
    if event is InputEventMouseMotion:
        print("a")
    else:
        print("b")

It prints a when I'm only using the touchpad and b when I'm also using keys

Godot version v3.2.3.stable.official
in Engine by (71 points)

1 Answer

0 votes
Best answer

It's probably not Godot which is causing that problem but your computer... or lag?

For reference: on my computer that code prints aa... when using my mouse and ab... when using my mouse and keyboard — what you would expect.

Godot like any game engine will try and record all input events every frame, but Godot won't actually send those events until the frame is rendered (to save performance!), but you can disable that behaviour.

Maybe on your system that's not working quite right? Try this:

func _ready():
   set_use_accumulated_input(false)

Is your system lagging? And do you have a wired mouse you could try out? Can you move the mouse while typing normally?

by (992 points)
selected by

On second inspection, my touchpad never works when typing, even on non-Godot games. It seems to work with a mouse.

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 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 webmaster@godotengine.org with your username.