I did single spawning ground but on arrays it doesn't works.
Here is my code
Thanks for attention
extends Node2D
const ground_spawner = [
preload("res://Scenes/Ground1.tscn"),
preload("res://Scenes/Ground2.tscn")]
const ground_width = 800
var spawn_position = global_position
onready var player = get_parent().get_node("Player")
func _ready():
pass
func _process(delta):
if spawn_position.distance_to(player.global_position) < 1000:
spawn_ground()
# my problem is in this function, maybe :) :)
func spawn_ground():
var spawn_ground_instance = ground_spawner.instance()
add_child(spawn_ground_instance)
spawn_ground_instance.global_position.x = spawn_position.x
spawn_position.x = spawn_position.x + ground_width
