Binding an object to another object (e.g. sword to the sheath, hand and moving it along with the hand) [3d]

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By SomeRandomGuy

I’m basically wondering how would be something like this possible. I am searching for a nice engine that would allow me to make a small RTS/City builder game with some RPG properties.

The question is, I want to make that a character is able to equip a weapon, where it’d be on the left side of their belt (sheath) - this is not an issue because I can just bind it by using coordinates and it’d work, but then there’s a problem with hitting with that weapon, because if I do the same as I said with the sheath, the weapon will always be in the same location as it was before, so if I get the position of the hand by calculating the position of the whole model (human), only the hand will move and I’d be unable to move the sword as I want to. Would it be possible to add a bone/node/something right on the model (in animations) to then refer to it via Godot in scripts?

TL;DR: Is it possible to refer to a bone/node/something that is bound to the animated model via GDScript to then bind objects to that bone/node/something? If needed, I can provide a screenshots of what I mean exactly.

:bust_in_silhouette: Reply From: metin

This should be easy. You can add the sword as a child of the hand bone. You can refer to bones like any other node.

Edit: Not true for 3D. You can use BoneAttachment.

Just to make sure I’ve understood you correctly:
I can make a bone in my animated model and then, via Godot, refer to that particular bone?

In case I wasn’t clear, the highlighted rectangle is a bone that Gothic game’s engine refers to to then bind a weapon to it.
enter image description here

It basically works like this, you choose a weapon you want to equip, you press the appropriate button and the item is created/moved in/to the highlighted slot (it’s actually inserted in another slot, but I’m just skipping unimportant/redundant parts). There’s no need to refer to that bone if you add a totally new item item that never existed in the game. The game recognizes usable items by “flags” (IDs in non-engine scripts) and then binds them to appropriate slots. I’d want to have the same effect. If what I say doesn’t make sense or is still misleading, I can record a video of how the game handles it.

PS: I don’t look for ready scripts, just to make it clear.

SomeRandomGuy | 2019-06-24 17:30

Ok, I have to correct myself because what I said is not true for 3D. In 3D you will need to use BoneAttachment, but it is just as easy.
See this short clip that someone uploaded. As you can see when he sets the bone attachment he gets a drop down menu with all the bones the character has.

metin | 2019-06-24 22:47

Here it is better to say

serega | 2019-07-02 13:10