Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an "added_child" signal to Node #11260

Closed
ObaniGemini opened this issue Sep 14, 2017 · 5 comments
Closed

Add an "added_child" signal to Node #11260

ObaniGemini opened this issue Sep 14, 2017 · 5 comments

Comments

@ObaniGemini
Copy link

ObaniGemini commented Sep 14, 2017

I think it would be good idea to have an added_child(child) signal to Node
I also don't think it would be very hard to implement, but in term of performances ? You guys are the knowledge owners on that point :)

Also, if this gets added, could it be merged for 2.1.5 ? 🙏

@Zireael07
Copy link
Contributor

Not sure on the performance end, but I can see tons of uses for the signal already :)

@ObaniGemini ObaniGemini changed the title Add a "added_child" signal to Node Add an "added_child" signal to Node Sep 14, 2017
@Zylann
Copy link
Contributor

Zylann commented Sep 15, 2017

While I see usages too, I never really needed such a thing. I mainly don't like the fact that not using it still makes you pay the cost of sending this signal for every node (also think about scene loading, which also adds nodes)

@eon-s
Copy link
Contributor

eon-s commented Sep 15, 2017

I don't see the usage of that.
I mean, the node that adds children to a specific node can call a group/notify the addition to interested nodes instead of every single node emitting signals, I think this workflow makes more sense.

Inserting a scene will result in the emission of many signals too like was mentioned before.

@akien-mga
Copy link
Member

Indeed, I think this would go against the signals philosophy of Godot.

Built-in signals are meant to notify about stuff which was not triggered directly by the developer; child nodes are only added when the developer requests it, by instancing and adding a scene/node, reparenting stuff, etc. Apart from some internal things like tooltip timers which shouldn't be used for game logic anyway, the engine would not add children without you requesting it.

As soon as an action is triggered by the developer, you can emit your own signal if that's relevant for your game logic (including from the animation player, which can also emit signals).

@akien-mga
Copy link
Member

You can use SceneTree.node_added for this use case now (#12224).

@akien-mga akien-mga added this to the 3.0 milestone Oct 20, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants