Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | JazzyB |
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
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?
jgodfrey | 2023-05-07 18:40
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.
JazzyB | 2023-05-07 19:11
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!")
jgodfrey | 2023-05-07 21:27
I see. I guess that will do. Thanks!
JazzyB | 2023-05-07 21:59