godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
91k stars 21.17k forks source link

`child_exited_tree` signal fires before child has exited the tree #59210

Closed markdibarry closed 2 years ago

markdibarry commented 2 years ago

Godot version

4.0 dev (d9f8cad)

System information

Windows 10

Issue description

The new child_exited_tree signal should fire once a child has exited the tree, but it fires too early.

Steps to reproduce

  1. Add a child node.
  2. Connect the child_exited_tree signal
  3. remove the child

Minimal reproduction project

childExit.zip

Calinou commented 2 years ago

For reference, this signal was added in https://github.com/godotengine/godot/pull/57541. cc @reduz

Mickeon commented 2 years ago

I wonder now, if it would be more useful to keep it as the child_exiting_tree signal...

markdibarry commented 2 years ago

Should we split this into two tickets? Rename child_exited_tree as child_exiting_tree and create a child_exited_tree signal?

wez470 commented 11 months ago

Can this be re-opened?

child_exited_tree was never created. I do see in the rename PR the author thought it was not needed, but I have a use case for it.

I want to use this for navigation. When a destructible environment object is destroyed, I want to re-bake the nav region, but the only hook I have is "exiting". So if I call bake in here, the nav mesh will still include the destroyed object. Yes, this can be worked around, but it's not ideal.

I find the slightly off parallels between enter and exit confusing. I initially saw "child_entered" and assumed the other would be "child_exited". Only after it wasn't working did I look closer and realize it was "exiting". "child_entering" and "child_exiting" or "child_entered" and "child_exited" make more sense as pairings (IMO), but we have a mix between the two currently.

AThousandShips commented 9 months ago

Please open a proposal for this as it's a new feature and this has been closed for a long while

wez470 commented 9 months ago

I actually just started a discussion here: https://github.com/godotengine/godot-proposals/discussions/9036