There are different ways to achieve that.
If you would like to drop the weapon and make it truly independent of the skeleton (e.g. keep the weapon lying on the ground to be picked up by the player), the best way would be to disable the weapon attachment at the skeleton and enable (or spawn) an identical weapon GameObject with the same weapon sprite image at the weapon bone's location. You can i.e. use a SkeletonBoneFollower
component to get the weapon bone's location. This way the weapon can be rendered independently of the skeleton, and you could e.g. disable the skeleton after some time or let the player pick up the weapon and move on with it.
The opposite approach would be to keep the weapon as part of the skeleton and override its location via a SkeletonUtilityBone
GameObject with mode set to Override
as soon as you want to detach it from the skeleton, which can also have physics components attached.
If you only need to apply physics to the sword, you could theoretically also base your approach on the SkeletonRagdoll
component, as shown in the Spine Examples/Other Examples/SkeletonUtility Ragdoll
example scene. Please also have a look at this forum posting here. The Starting Bone Name
parameter would then be your weapon bone instead of the hip
bone.
Another approach would be to attach the weapon as a GameObject (again using e.g. a BoneFollower
component), and then simply detaching it when needed by no longer letting it following the weapon bone.