0 votes

I want to swap the positions of the children in a VboxContaine.
For example having an "add child button" that's always in the last place even after adding a new child, I guess I could just destroy and add it back again. But what if I want to swap the fourth item starting from the top for the second?

Thanks in advance.

in Engine by (397 points)
edited by

1 Answer

+2 votes
Best answer

You can call move_child():

move_child(get_child(3), 1) # move 4th to 2nd, 2nd pushed to 3rd
move_child(get_child(2), 3) # move 3rd to 4th
by (4,165 points)
selected by

Thanks this works I was looking in the documentations inside the containers and couldn't find it, guess I had to go higher on the tree.

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.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.