Godot Version
v4.5.stable.official
Question
I have 2D project in godot whereI want to spawn a grid of objects.
I used script for spawning that worked in my previous 3D projects but the spawned grid is immediately deleted after spawning.
Here is the script fo spawner it self.
func spawn_entity(entity_id: String):
var entity = general_entity_instancer.return_entity(entity_id).instantiate()
chunk_manager.add_child(entity) #spawn do objektu
print(entity)
entity.set_global_position(self.get_global_position()) #globalni pozice
and here is a script for creating the grid
func spawn_grid(array):
var default_pos = position
for i in height:
if i != 0:
entity_spawner.position.y+=1
entity_spawner.position.x = 0
for j in width:
if j != 0:
entity_spawner.position.x += 1
entity_spawner.spawn_entity(array[i][j])
print("X: ",entity_spawner.global_position.x," Y: ",entity_spawner.global_position.y)
entity_spawner.position = default_pos
here is the script I am running in the main scene
func _process(delta: float) -> void:
if !chunk_spawned:
chunk_manager.spawn_grid(chunk_manager.array_functions.create_grid())
chunk_spawned = true
Does anybody know what might be wrong?