27 lines
581 B
GDScript
27 lines
581 B
GDScript
extends Node
|
|
|
|
# child_node_appender.gd
|
|
|
|
# All children of this node will be moved onto the node that is specified by
|
|
# provided path relative to the parent of this node
|
|
|
|
@export var relative_path: String
|
|
|
|
func _ready() -> void:
|
|
var parent := get_parent()
|
|
|
|
if parent == null:
|
|
push_error("Child Node Appender has no parent")
|
|
return
|
|
|
|
var node := parent.get_node_or_null(relative_path)
|
|
|
|
if node == null:
|
|
push_error("Provided path does not resolve to a node")
|
|
return
|
|
|
|
var children := get_children()
|
|
for child in children:
|
|
remove_child(child)
|
|
node.add_child(child)
|