Parenting an Object to a bone or get a similar effect with other methods

I have a player object which has a box in his hands as a placeholder for a weapon. To attach a weapon I set it’s parent to the weaponPlaceholder of the player.

This worked fine for static player object. If, however, it is animated with bones, the weapon does not move along.
So I tried parenting the weapon placeholder to the armBone of the players’ skeleton which works fine in Blender. But apparently, Babylon does support a bone as a parent for an object. Neither by importing from a glb nor by setting the relationship in code.

Did I just do it wrong both times or is this really not supported? How can I reach a similar effect in Babylon?

1 Like

I wish this was supported. I thought it might be, as I haven’t tried this in recent versions.

Anyway, The only work around I can think of currently is to parent your bone to a mesh, and then parent your prop to the same mesh. When you animate the parent mesh, the behavior will be what you’re looking for.

Galen

2 Likes

No worries :slight_smile: We’ve got you covered !
You can attach a mesh to a bone:
https://www.babylonjs-playground.com/#11BH6Z#399 (line #43)

2 Likes

Thanks, it’s working like a charm.

1 Like