Within multiple autoloads _input() is called in reverse execution order

Godot Version

Godot 4.4.1

Question

In an input system im working on, i noticed that with multiple autoloads in my project, _input() runs in the opposite execution order compared to _ready(), _process() and _physics_process().
Below ive written out how to replicate my issue.

Steps to Reproduce:

  1. Create three autoload scripts (AutoloadA, AutoloadB, AutoloadC)

  2. Add them to Project Settings → AutoLoad in that order:

  3. Add this debug code to each script:
    extends Node

var limiter = 1
var process = 0
var p_process = 0

func _ready():
print(name, " _ready()")

func _input(event):
if event is InputEventKey and event.pressed:
print(name, " _input()")

func _process(delta):
if process >= limiter:
return
print(name, " _process()")
process += 1

func _physics_process(delta):
if p_process >= limiter:
return
print(name, " _physics_process()")
p_process += 1

  1. Run the project and press any key

Expected Behavior:
All methods should execute in the same order (top to bottom):
AutoloadA _ready()
AutoloadB _ready()
AutoloadC _ready()
AutoloadA _physics_process()
AutoloadB _physics_process()
AutoloadC _physics_process()
AutoloadA _process()
AutoloadB _process()
AutoloadC _process()
AutoloadA _input()
AutoloadB _input()
AutoloadC _input()

Actual Behavior:
_ready(), _process(), and _physics_process() execute top to bottom, but _input() executes bottom to top:
AutoloadA _ready()
AutoloadB _ready()
AutoloadC _ready()
AutoloadA _physics_process()
AutoloadB _physics_process()
AutoloadC _physics_process()
AutoloadA _process()
AutoloadB _process()
AutoloadC _process()
AutoloadC _input() ← Only _input() is reversed
AutoloadB _input()
AutoloadA _input()

Is this intended?
If so, is there any way that i can make _input() get executed in a different order for my autoloads?

The order of _input() is explained in the documentation:

When sending events to its child and descendant nodes, the viewport will do so, as depicted in the following graphic, in a reverse depth-first order, starting with the node at the bottom of the scene tree, and ending at the root node. Excluded from this process are Windows and SubViewports.

3 Likes

Ah I see. Thank you for the help!

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