Problems attaching entities in the bones of a character

Hi I’m having a few problems with objects attached in the bones of my animations.

I’ve imported a fbx which has the eye and ears of the model attached in the head bone. But when the animation plays this objects do not move along with the animation. But works fine in Maya, Blender and Unity.

One other issue is when I try to reparent one entity into a bone, the global positions end rotations of this entity changes. Look’s like the entity tries to keep it’s local values and changes the global values. Is there a way to make the opposite?

Hi, can you post the link to your project coz it’s hard to point out a solution without see it

mmmh i see seems u have a pretty complex model made with different parts, i guess you have to re-attach them with a script, to do that you have to know the bones names, if u don’t know that you can find it by clicking 2 times on the json animation file and looking into it, if u search in this forum you can find also another way but i don’t remember it actually. You have to put the parts you want to attach as child of the entity that contain your model, the script must be like this

equip_sword: function () {
this.rhand = this.model.findByName(‘Bip01 D Mano’);
// 2 following lines to place the item in the right position
this.sword.setLocalEulerAngles(90, 0, 90);

I’m still having trouble with this reparent function. If the entity is already on the correct global position and rotation and I reparent it, this entity shouldn’t translate, but only be held by the new parent, kipping it’s global values.

You can getPosition of child, reparent, and setPosition back to what it was.

I had the same problem, that’s why in the script u see the setLocalPosition and the setLocalEulerAngles, the problem i guess is due by the different sizes of the models, so when u attach it the position of the child change, so u need to adjust that every time you attach or detach it. I suggest you to set a variable with the position when the object is detached and readjust the position when you attach it like in the example
PS maybe you also have to rescale it if you remove it from it’s parent object

Well, you could do:

function reparentLockTransform(child, parent) {
    var pos = child.getPosition();
    var rot = child.getRotation();

Thanks for the tips guys! Helped a lot!

1 Like