Detecting children of a node

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By MemokingMH

I ihave a node2d in my scene(Named enemies) and I basicly instance enemies as a child of it’s. I wanna detect when all the enemies are killed aka. when there is no child left as a child of node2d. I tried checking children count in process function bt it returns true every frame of childlessness, I just want the exact moment to trigger a function

:bust_in_silhouette: Reply From: jgodfrey

You’re probably looking for get_child_count(), which does as it says. It should return 0 when a node has no children. Though, you’ll have to ensure you’re actually removing the children when they’re killed for this to work…