_input() function is completely broken

Godot Version: 4.2.1 Stable.mono


This is why I try to avoid making games in high level languages.

The _input() function has completely stopped working.
In other projects I’ve done it worked fine but for some reason, it will not trigger even after explicitly setting set_process, it still refuses to execute the _input() function.

All I’m trying to do is create a pause function which would normally be easy in a proper language like C++ because you could just detect a keyscan in the main loop which would start a while loop that would wait for another input. But no. GDscript is absolutely incapable of detecting input at all apparently starting today (3/8/2024).

For context, here is the function that works:

I know these functions do different thing and are in different projects but one gets triggered and one doesn’t. Input should work the same regardless right? Project settings are basically default aside from some basic metadata. Input map is also default on both projects.

#function that works:

func _input(event):
	if Input.is_action_pressed("ui_cancel"):

# and here is the function that doesn't work:
func _input(event):
	print("input function triggered.")
	if Input.is_action_pressed("ui_cancel"):
		print("pause pressed")
		is_paused = !is_paused
		get_tree().paused = is_paused

Are you asking for a program that pauses it?

I’m trying to understand why the _input() function doesn’t detect any input at all.

To be clear, are you saying the whole program doesn’t work? or do some of the parts work etc print(“input function triggered.”)

Well, once you call get_tree().paused = true, the whole node tree will stop receiving input events. Unless you change the property Node > Process > Mode of the particular mode.
Check out this video: https://www.youtube.com/watch?v=kn8yOGEvCo0


Nope No input is detected whatsoever in this scene. Button nodes work just fine but keypresses and mousebutton presses are not. I put a print statement at the beginning of _input and nothing happens when I press keys.

I can pause the game with an _on_button_press() function.
those work just fine. the problem is when I use a button press function, they can’t unpause the game.

1 Like

Honestly, a small workable demo would help a lot. Also format your code with </> tool. Help us help you.


If you want to talk “proper language”, maybe you need to just write your game in assembler and not some as high-level as C++.

1 Like

The problem is that the _input() function is simply not being triggered at all. No keyscan or mouse button press will trigger the function and I have no idea why. My game is RTS resource management game that uses very little input because most of the interaction is through buttons, sliders, menus. ect. this is why I’m adding the _input() function so late in the development cycle but I honestly didn’t think it would make much of a difference.

I watched your video and noticed there was an underscore in event parameter when you created the input function. I don’t know what the significance of that was but it doesn’t seem to make a difference when I add it to my code.

I don’t know if it has to do with the fact that the root node script I’m calling it in is quite large (almost 600 lines) and I triple checked that I didn’t have another input function somewhere in it hiding.

Node has a process_mode property, which is set to PROCESS_MODE_INHERIT by default. It needs to be PROCESS_MODE_ALWAYS, if you want _input() to work always.

Also, set_process() only enables or disables _process(). For enabling or disabling _input() you need to use set_process_input().

The number of lines in the script is irrelevant to the problem.


Nope. still doesn’t work. I added the following lines to the _ready() function:

	process_mode = Node.PROCESS_MODE_ALWAYS

there are still is still nothing detected by the _input() function.
I found this error in the debugger and I don’t know if it has anything to do with why input is not being handled or not.

I should probably add that I can make input functions in every other scene in my game and they work just as intended with no issues whatsoever. Even after explicitly setting set_process_input() to true and the process mode to always, I’m still having these issues. Is there any other thing that would cause _input() to simply not work?

Here is an error I found at runtime and I wonder if it has anything to do with the issues I’m running into.

E 0:00:02:0405   _push_unhandled_input_internal: Condition "!is_inside_tree()" is true.
  <C++ Source>   scene/main/viewport.cpp:3390 @ _push_unhandled_input_internal()

I don’t usually make forum posts about stuff unless I’m desperate. I have used every game engine from pygame to unreal and never encountered an input handler this frustrating. Not because of how it works, but because it simply doesn’t.

I’m not familiar with the source code, but it looks like for some reason the Viewport is not in the SceneTree, when it tries to handle input. This is likely related to the problem.

Alright. I found the reason this is happening and a work around.
The reason this is happening is because my viewport is covered in tiled static windows which “blocked” (for lack of a better word) the input from reaching the root node. Once I moved one of these windows to expose the grey background, I started getting input.

This is confusing because everything I’ve read in the documentation for _input(), indicates to me that input starts at the root node and travel up the tree until it’s captured by something. I never would have guessed that the windows I created would be blocking it. but it is what it is.

What I ended up doing is just creating a separate scene and making that my pause menu rather than trying to make _input() work.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.