extends Node2D var active : bool = false var next_spawn : float = 3 var spawn_delay : float = 3 # Called when the node enters the scene tree for the first time. func _ready() -> void: pass # Replace with function body. # Called every frame. 'delta' is the elapsed time since the previous frame. func _process(delta: float) -> void: if active: next_spawn -= delta if next_spawn <= 0: spawn_obstacle() spawn_delay -= spawn_delay * 0.02 next_spawn = spawn_delay func spawn_obstacle(): var randy = randi_range(0,360) #y pos to spawn the new obstacle at var new_obstacle : Node2D = load("res://Prefabs/obstacle.tscn").instantiate() new_obstacle.global_position = Vector2(global_position.x, randy) get_tree().get_root().add_child(new_obstacle) func _on_lander_moved() -> void: active = true