I'm new to gdscript so bear with me, I have been trying to make a script that generates a grid automatically by instancing a scene multiple times, letting me change the size of the grid more easily. it looks like this:
var tile = load("res://Battle.tscn")
func _ready():
create_grid()
func create_grid():
var gridloadH = 6 #Horizontal size
var newTile = tile.instance()
var tilePosH = Vector2(160, 96) #Horizontal position of the tiles
for i in range(gridloadH):
add_child(newTile)
tilePosH += Vector2(64, 0) #moves each new tile instance by 64 squares in X axis
newTile.position = tilePosH
print("tile added")
The problem i'm having is that each time I run this scrip only 1 tile is added, it's possition is (544, 96) on the canvas. wich makes me think that maybe each tile is being added but they are all being moved to the same place, causing them to overlap and looking only like 1 tile. I dont really know what to do to solve this, any help appreciated.