![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | soul_gugu |
I create 3 maps which will be appended at the end of current map randomly. Element structure of my level is:-
Node2d
|-Player
|-TileMap //initial map
|-Spawner(a 2d Node) // responsible to append levels in future
Following script is attched to spawners:-
extends Node2D
export(Array,PackedScene) var scenes
var random_scene=RandomNumberGenerator.new()
var selected_scene_index=0
func _on_Timer_timeout():
random_scene.randomize()
selected_scene_index=random_scene.randi_range(0,scenes.size()-1)
var tmp=scenes[selected_scene_index].instance()
add_child_below_node(self,tmp)
The code is working as expected,i.e., generating maps but how can i set the position of maps so that they appear after one another and do not overlap.