How to select the first child of a node

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

hello, im new in godot. im trying to remake flappy bird game using godot 4. I want to delete the pipes, a solution i can think is to select the first node and delete it. but i dont know how to select the first child of a node in godot

Thank you so much.

:bust_in_silhouette: Reply From: AgungGD

Silly me, i can just use get_child(0) function to do it

:bust_in_silhouette: Reply From: AndyAstrand

Hi, the Node class has what you need.

Node Class Docs

yourNode.get_child(0)  -- Will get the first child
yourNode.get_child_count() -- Will tell you the number of children
yourNode.get_children() -- Returns a list that you could iterate as below:

for yourChild in yourNode.get_children():