Godot Version 4.2.2
Question
Hey all,
I’m a total beginner with Godot and learning how stuff works.
What I’m trying to do is create multiple buttons and then change their position.
For the first generated button I can use the $GroupForMain/Building.position
but the second one is $GroupForMain/@Button@2.position and so on.
How come its naming is changed to its type and is there a way to make them all the same or at least get the list of all the buttons under the $GroupForMain so I could loop through it to change positions?
var buildingButton: PackedScene = load(“res://building.tscn”)
func add_new_building():
var buildingInstance = buildingButton.instantiate()
$GroupForMain.add_child(buildingInstance)
func _ready():
add_new_building()
add_new_building()
add_new_building()
$GroupForMain/Building.position = Vector2(300, 300)
$GroupForMain/@Button@2.position = Vector2(400, 400)
$GroupForMain/@Button@3.position = Vector2(500, 500)