Describe the project you are working on: I'm working on a space shooter and in a city sim. Both projects have a main actor/controller represented by a node in the tree containing very important information, wich is required and also generated by his brothers.
Describe the problem or limitation you are having in your project: Is normal from any program that whenever a node needs information about a brother, it calls the father.
At the beggining of the scene execution i need the father node to get a "pointer" to the child which will be either passed to all the other children if the information is specific for each one, or will be preserved to carry methods passing it processed. In this case i have the problem that putting this on _ready() ends with two cases:
- If the children ask the parent first (_ready() order), he will have no information for them as he would not have the oportunity to search for the child node.
- The parent would send a message for each children after getting the pointer on _ready(). This error-safe but the parent would have to filtrer and iterate on the information before passing it, which can be complicated as they will be a LOT of them.
The problem is basically that _ready() operates in a different order than _process() .
Describe the feature / enhancement and how it helps to overcome the problem or limitation: Having another function called when the tree is ready, but in inverted order. The parent searches for the children to be knows and the broters take all the necesary information. Everything happens on _inverted_ready()
Describe how your proposal will work, with code, pseudocode, mockups, and/or diagrams: This would not be its name but holds the idea.
_inverted_ready() # called after the tree is complete from root to children
pass
If this enhancement will not be used often, can it be worked around with a few lines of script?: It kinda can be done yes. But the problem augments and ,makes a lot of pieces a bit more complicated.
Is there a reason why this should be core and not an add-on in the asset library?: Is a core functionality. As I know it can't be implemented on a plugin.
Have you tried using call_deferred ?
What do you mean by "inverted order" ? From root to leaf ? If it's that order you are looking for you can use _enter_tree which does exactly that.
_inverted_ready() # called after the tree is complete from root to children
Well in that case, from the scene's root, you can call propagate_call in _ready : propagate_call("_inverted_ready").
I did't knew about the propagate__call(). I will implement it now.
@Mautar55 Did you find a solution to your problem using propagate_call()?
Yeah. Put a propagate_call("_start") on the script of the first child of the root.
I'll close this, as it seems OP has found a workaround to the particular issue they were encountering.
Most helpful comment
What do you mean by "inverted order" ? From root to leaf ? If it's that order you are looking for you can use
_enter_treewhich does exactly that.Well in that case, from the scene's root, you can call propagate_call in
_ready:propagate_call("_inverted_ready").