Connecting dependencies of nested nodes/objects inside the root main component?

Godot Version



Hey all, started a course on Godot and I wanted to get your opinion on the best approach to pass dependencies to nested Nodes.

I have the following main scene:

Now inside Player is the following:

And SwordAbilityController:

Now inside of SwordAbilityController when the Timer ends, a reference to Player and the Enemies is gotten via groups like get_tree().get_nodes_in_group(“enemy”) and get_tree().get_first_node_in_group(“player”), and then one deals damage to the other, for example. Both player and enemy have been added to groups of course.

This is according to the course.

Now I felt strange having to reference Player and Enemies directly like this so I thought I would pass the dependencies via a setup function in SwordAbilityController, and removed the groups:

After this I call this setup function from a script attached to Main:

Now being a developer myself, but since I am new to Godot and gamedev, I am trying to understand what a scalable approach for the future might be, where I have cases like these. I could propagate the Timer end signal all the way up to the Main root node, however this would cause too many signal bubbling, as per this so

So is there anything wrong with this or do you thin this is perfectly fine also for other such controllers and so on?


try global event bus, so you dont need to pass signal from one child to parent to parent to parent again like this.,Global%20Event%20Bus,-In%20GoDot%20we