crystal-bit / godot-game-template

Generic template for Godot games
MIT License
611 stars 48 forks source link

Add `reparent_to()` #9

Closed davcri closed 3 years ago

davcri commented 3 years ago
func reparent_node(node: Node2D, new_parent, update_transform = true):
    var previous_xform = node.global_transform
    node.get_parent().remove_child(node)
    new_parent.add_child(node)
    node.global_transform = previous_xform

This is not implemented in Godot because it's easy to do with GDScript.
However it seems like a handy feature to have in a game template (and also to avoid duplicating code).


Relevant Godot issues: