• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

SOLVED Spine - skeleton_attachment_set not working in an IF statement

knightshaft

Member
In "Create"
skeleton_attachment_set("Rear-Hand", "Brown/front-fist-closed");
works fine

In "Step"

GML:
if (Engine_obj.step_counter<20) {

    show_debug_message("Attach: x");

    skeleton_attachment_set("Rear-Hand", "Brown/front-fist-closed");

} else {

    show_debug_message("Attach: y");

    skeleton_attachment_set("Rear-Hand", "Brown/BackHand");

}

sag = skeleton_attachment_get("Rear-Hand");

show_debug_message("Attach: "+string(sag));
The following debug code is output:

Code:
Attach: Brown/front-fist-closed
Attach: x
Attach: Brown/front-fist-closed
Attach: x
Attach: Brown/front-fist-closed
Attach: x
Attach: Brown/front-fist-closed
Attach: x
Attach: Brown/front-fist-closed
Attach: x
Attach: Brown/front-fist-closed
Attach: x
Attach: Brown/front-fist-closed
Attach: x
Attach: Brown/front-fist-closed
Attach: y
Attach: y
Attach: Brown/front-fist-closed
Attach: Brown/front-fist-closed
st-closed
Attach: y
Attach: Brown/front-fist-closed
Attach: y
Attach: Brown/front-fist-closed
Attach: y
Attach: Brown/front-fist-closed
Attach: Brown/front-fist-closed
st-closed
Attach: y
Attach: Brown/front-fist-closed
Attach: y
Attach: y
Attach: Brown/front-fist-closed
Attach: Brown/front-fist-closed
st-closed
Attach: y
Attach: Brown/front-fist-closed
The "else" statement runs but the skeleton_attachment_set does not set! What am I missing!?
 

rIKmAN

Member
Make sure that you are spelling the attachment name correctly, including case.

I'd recommend you use some sort of consistent naming convention as your current one is all over the place and each item uses a different type:

Rear-Hand
BackHand
front-fist-closed

Pick one naming system and stick to it, it will make it much easier to remember as your project grows and skeletons get more compelx.
 
Last edited:

gnysek

Member
You're saying, that in create all works fine, and then we can see, that in step event SAME attachement name works fine, while other not. So I'm suspecting that there's problem with "Brown/BackHand", as this one isn't given in your examples as working anywhere.
 

knightshaft

Member
You're saying, that in create all works fine, and then we can see, that in step event SAME attachement name works fine, while other not. So I'm suspecting that there's problem with "Brown/BackHand", as this one isn't given in your examples as working anywhere.
I've done a bit more testing and skeleton_attachment_set doesn't seem to work anywhere. Which ever attachment is active at the time of export from Spine is the one that is set. So it looks like I'm either doing something wrong in Spine or I'm not using the skeleton functions correctly.
 

knightshaft

Member
Turns out you can't switch between images in 2 different skin placeholders, even if they are on the same slot.

I moved the images from the placeholder to the parent slot and it worked fine.
 

rIKmAN

Member
Turns out you can't switch between images in 2 different skin placeholders, even if they are on the same slot.

I moved the images from the placeholder to the parent slot and it worked fine.
Glad you found the problem.
I'd still recommend getting into the habit of using a consistent naming convention going forward, it'll save you so much time and many headaches in the future.
 
Top