Question - Code [SOLVED]Spine Attachment Not Changing

Edit: Nevermind, it is working now.

This is code to make a character blink in Spine.


The Idle animation uses the "Eyes 1" attachment, and the Run animation uses the "Eyes 4" attachment.

The blinking code below works for the "Eyes 1" attachment, but doesn't work for the "Eyes 4" attachment.

When my character is on the Run animation for example with the "Eyes 4" attachment on, then the Eyes slot never gets set to "Eyes 2". It keeps looping the alarm[0] every 10-20 frames. I am guessing this is a bug, but I want to make sure if anyone knows how to fix this before reporting.

Can I get any help with this?


[Slot] - Eyes
[Attachment] - Eyes 1 - (Idle eyes)
[Attachment] - Eyes 2 - (Blink eyes)
[Attachment] - Eyes 4 - (Run eyes)


Create Event
Code:
skeleton_animation_set("Idle");

//Sets eyes to "Eyes 1"
eyes = skeleton_attachment_get("Eyes");

alarm[0] = 5;


Alarm 0 Event
Code:
if (skeleton_attachment_get("Eyes") != "Eyes 2") {
 
    //Makes the character blink

    skeleton_attachment_set("Eyes", "Eyes 2");
    alarm[0] = irandom_range(10, 20);

} else {

    //Sets the Eyes slot back to the eyes used by Idle, or Run

    if (skeleton_animation_get() == "Idle") {
        eyes = "Eyes 1";
    } else if (skeleton_animation_get() == "Run") {
        eyes = "Eyes 4";
    }

    skeleton_attachment_set("Eyes", eyes);
    alarm[0] = irandom_range(250, 260);

}
 
Last edited:
Not sure if it's what your problem was but I've found you have to run skeleton_attachment_set() every single frame to keep an attachment changed, which is kind of a pain compared to just setting it once and it stays like that. I do it in the Animation Update Event.
 

rIKmAN

Member
Not sure if it's what your problem was but I've found you have to run skeleton_attachment_set() every single frame to keep an attachment changed, which is kind of a pain compared to just setting it once and it stays like that. I do it in the Animation Update Event.
I’m pretty sure that shouldn’t be the case, maybe it’s a bug that was reintroduced in one of the updates but you should be able to set once and it will stay changed.
 
I think it is because the Eyes slot on frame 0 of the Run animation was being changed to "Face 4", so I removed this from the animation itself and it started working.

I think changing an attachment in the actual animation, and then trying to change that attachment through code doesn't work I believe.
 
Top