0 votes

If I'm not wrong, add_child adds a node in the last position of his parent. There's an additional function add_child_below_node that allows adding a node after to another specific one, so you can add a node in index 1, index 2, index 3, etc.. but never as first one.

  1. Am I right?

  2. How can I add a node at index zero, then?

  3. Why there's no function for adding at specific index? Or at least for adding above node so we can use it to add as first node. Maybe I should add an issue on this, but I'm surprised there's no way to do such a simple thing and maybe there's a reason for it (couldn't find it tho)

Thanks!

asked May 25 in Engine by jluini (91 points)

In my case I want to do this for adding elements to a HBoxContainer in specific positions and could use a fixed empty node as first child as a workaround.

1 Answer

0 votes
Best answer

after `add_child()

move_child(child_ref, 0)
answered May 25 by LoneDespair (315 points)
selected May 25 by jluini

Thanks! That answers my first two questions and makes the third one pretty irrelevant.

glad to help :)

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.