Topic was automatically imported from the old Question2Answer platform.
Asked By
lalel345
I have deleted all the children of the node, how do I add them again?
func _physics_process(delta):
if Input.is_action_just_pressed("ui_accept"):
for i in get_children():
remove_child(i)
if Input.is_action_just_pressed("ui_cancel"):
for i in get_children():
add_child(i)
this code makes that when pressing a key I delete them and when pressing another attempt they return but it does not work
var childrens = []
func _ready():
for i in get_children():
childrens.append(i)
func _physics_process(_delta):
if Input.is_action_just_pressed("ui_accept"):
for i in childrens:
if i.is_inside_tree():
remove_child(i)
if Input.is_action_just_pressed("ui_cancel"):
if get_child_count() == 0:
for i in childrens:
add_child(i)