hero-mark-2/objects/delayed_instance.gd

23 lines
430 B
GDScript

extends Node
export var delay = 0.0
export var autostart = false
var children = []
func _enter_tree():
for child in get_children():
children.append(child)
remove_child(child)
func _ready():
if autostart:
start()
func start():
get_tree().create_timer(delay, false).connect("timeout", self, "_instance_children")
func _instance_children():
var parent = get_parent()
for child in children:
parent.add_child(child)