How to parent another object

Godot Version

Godot 4.2

Question

How do i reparent the sword object to a bone attachment, and how do i reparent it back to swordhand? Please help

$Armature/Skeleton3D/SwordHand/Sword.reparent($Armature/Skeleton3D/SwordBack)

Captura de pantalla 2024-11-25 112132

Seems like this would work for parenting it one way, does it give you an error? What goes wong with this code?

If you store a reference to the sword you can easily reparent it many times

For your use case you might want to use the second parameter keep_global_transform

@onready var sword: Node3D = $Armature/Skeleton3D/SwordHand/Sword

sword.reparent($Armature/Skeleton3D/SwordBack, false)
sword.reparent($Armature/Skeleton3D/SwordHand, false)
1 Like

Thanks!!!1 it works