This is my project structure:


And this is my code, using Pixi-spine:
this.spine.skeleton.setAttachment('weapon_primary', 'sword'); // Doesn't work
this.spine.skeleton.setAttachment('back_shield', 'shield'); // Works
Why is that the first setAttachment doesn't work, but the second does? What I mean by doesn't work, is that the changes do not appear. When I call that code, I'll see a shield appear on the player's back, but not a sword in their hand.

I get no warnings either. Putting in an incorrect attachment name, such as:
this.spine.skeleton.setAttachment('weapon_primary', 'sword_abcdefg');
Results in an error as expected. So I find it weird that it doesn't appear without any warning.
Posts: 5


The screenshot is unfortunately not showing the whole list, I guess?

Note that setAttachment only works when nothing else is setting the attachment.
For example, your currently playing animation has "weapon_primary" keyed, it will show that instead of "sword", every time the animation is applied.
The way to override a keyed attachment would be to set the attachment every frame, and only at the point after the animation is applied. Not before, or the animation will override the attachment you set.

The other way to do this is to have a Skin at runtime that you manipulate.
For example, if your currently playing animation has "weapon_primary" keyed, set the skin so that "weapon_primary" points to "sword".

I'm not sure how pixi-spine handles empty or non-existent skin entries.
User avatar

Posts: 4949

Return to Editor