_input is never called

Godot Version

4.4.1

Question

I am trying to make a simple pong-like game. For the mouse movement, I want to use _input, like it is shown in the tutorial: 2D movement overview — Godot Engine (stable) documentation in English

This is my code:

func _input(event: InputEvent) -> void:
	print("Input")

But the print statement does not show; _input is never called. I read here in the forum that you need to call “set_process_input” in _init, but that did not help.

What do I need to do to get _input to work?

The node/script only has to exist in the scene tree, with the correct process mode. The default process mode (inherit) will work if your game is unpaused (which it will also be unpaused by default). You only need to call set_process_input(true) if you called set_process_input(false) before, it is enabled when the function is overriden, does not need to be manually enabled.

Can you share a screenshot of your scene tree?

Is there something else in the scene that might be consuming the input?

I am currently not at the computer that contains the project, but I can post the scene tree tomorrow. The scene contains only a sprite2d though; maybe it is because I attached the script with the _input function to the sprite?

So I thought it wood be a good idea to create a sample project to highlight my problem - and _input worked right out of the box.

Then, I returned to my original project, and it works as well, without any changes.

I have no idea why. The only difference is that I restarted my computer in the meantime. Maybe some OS update got “stuck” in the background.

Anyway, thanks to both of you for your support!

1 Like