This site is currently in read-only mode during migration to a new platform.
You cannot post questions, answers or comments, as they would be lost during the migration otherwise.
0 votes

Hello. I'm having a problem that I don't really know how to deal with.
Basically, I want my game to ignore the mouse completely on engine level (as if the mouse was never there in the first place). I've noticed that if I, for example, put

print(event.as_text())

in the _input function and mouse over the game window, it prints mouse events, and I don't want this to happen at all.
In short, I want my game's _input to not even see the mouse, much less react to it.
Any help is appreciated!

Edited to clarify what I meant

Godot version v4.0.2.stable.official [7a0977ce2]
in Engine by (15 points)
edited by

I've noticed that when I try to do something in the _input function, it reacts to the mouse moving over the window

I'm not sure I understand this statement. What does "reacts to the mouse moving" mean? Also, what does the code in your _input function look like?

If I, for example, put

print(event.as_text())

in the _input() and then move my mouse a bunch over the game window, it prints all kinds of mouse movements. I need mouse to not trigger _input() at all, this is what I've been trying to say.

If you don't put code in _input(), no input will be processed. If you have code there, that's telling the engine that you want to process input. If you want to process input, but not mouse input specifically, you need to wrap your _input() code so that's it's only processed based on the movement type(s) you want to process.

For example, to process input, but NOT mouse input, something like this will work:

func _input(event):
    if !event is InputEventMouse:
        print("Input from something that's not the mouse!")

I see. I guess that will do. Thanks!

1 Answer

0 votes
Best answer

Based on the above discussion, the answer is one of...

  • Don't put code in _input if you don't want to process any input, or...
  • If you do need to process input, but not mouse input specifically, filter the input based on its type. For example...

.

func _input(event):
    if !event is InputEventMouse:
        print("Input from something that's not the mouse!")
by (22,704 points)
selected by
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.