+1 vote

I was using an older tutorial that used the fixed process function, and also a built in function called func _input(event). It also put, setprocessinput(true). Is this still applicable to the current version of Godot?

The tutorial mentioned that functions that check for input should be but in this function, instead of the fixed process function (now physics process funtion). Is that still true?

in Engine by (391 points)

1 Answer

+1 vote
Best answer

Yes, the function is still used, if you want to catch all input events regardless of anything (even if some UI is shown).
It is now enabled by default if you declare it, so no need to do set_process_input(true), unless you want to turn it off.

by (29,088 points)
selected by

Thanks for responding. So, if I check for a lot of input, I should put it in the input function instead of the physics process function? In the tutorial, when the input code was copied from the fixed process function and pasted in the input function, it broke the game, and extra tweaking had to be done to make it work. Will that still need to be done?

Checking input with the Input singleton and using the _input method are two very different ways of handing input.

The Input singleton checks realtime input states, even though it has some event-like methods. It means no matter what happens in the game or the engine, it will tell you the current input. That also means it doesn't check anything like pause mode, GUI in front of the player or text fields being in use etc, those cases are up to you to manage manually.

The _input method (and its _unhandled_input and _gui_input counterparts) go the other way around: they gets called only when input changes (or events) actually occur, so it doesn't run every frame, only when it needs to. Because of that, it is often preferred when GUI interaction comes in, because the engine can decide when your code gets called (i.e if a window blocks the mouse, it will send clicks to the script on that window, and not the game behind it).

All this design didn't change much in 3.0, check this http://docs.godotengine.org/en/3.1/tutorials/inputs/inputevent.html

Thnx for the info :)

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.