Problem with bone attachments

Im trying to attach something so any bone of a skeleton, for example a sphere I imported.

this is how I do it:

Node attachment=(Node)m.getAssetManager().loadModel("/Models/testModels/sphere.mesh.xml");

Skeleton skeleton=control.getSkeleton();

Node boneNode=skeleton.getBone(17).getAttachmentsNode();

boneNode.attachChild(attachment);

m.getRootNode().attachChild(boneNode);



the sphere is visible and it seems to move correctly, but it is at the completely wrong position, wich it doesnt even change when the character moves.

I tried to set the localtranslation of the attachment or the localtranslation of the bones attachmentsnode, but it didnt work, the object is still far away from the bone. what should I do?

Use SkeletonControl.getAttachmentsNode() instead of Bone.getAttachmentsNode()

It will return a node already attached to the model, so you don’t need to attach it yourself.