How do I make several nodes line up and move up when the first one is removed? (GDscript)

14 Views Asked by At

I'm making a clicker in Godot, and I want the upgrades to line up in a way so that once you buy an upgrade, the next upgrade(or node) moves up to fill in the position. It's kind of hard to explain it, but I think you should get the gist of it. As a beginner programmer, I have no clue how to do that.

I haven't tried anything yet, since I have no idea where to start.

For clearer examples, consider 3 nodes, and the positions being (0,0), (1,0), and (2,0). (I will edit those positions later if I need them)

The first one is at (0,0) and when the first node is removed, the second one takes its place, and the third node takes the second node's place etc. Also when I mean disappear/removed, I just mean probably once you've clicked on it with the right amount of resources, (clicker game) it runs its code and it sets visibility to false.

1

There are 1 best solutions below

0
Theraot On

A VBoxContainer will have the behaviour you describe. Containers will ignore hidden Controls, and VBoxContainer that will organize its children vertically (i.e. in a column).

You might also want the Controls to steadily move up. You could archive that using a tween to reduce the size of the Control you are about to hide. However, I would like to encourge you to focus on making it functional first.

I'll also remind you to set the disable property of Buttons when they should not be clickable.