• 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!

Spine animation mix help

asollazzo

Member
Not sure this is the right forum section to post in but i need some help with skeleton_animation_mix and spine. I have say 100+ animations and the majority of them need to blend into each other, so in the create event i have about a million lines of skeleton_animation_mix("animation1", "animation2", 0.5);

Is there any way through code i could blend every animation on a skeleton to a default 0.5 and then just manually change the rest that need something specific?
 

Phil Strahl

Member
You could use a global variable, e.g.
Code:
global.spine_default_blend = .5
and have your code read
Code:
skeleton_animation_mix("anim1", "anim2", global.spine_default_blend)

Whenever you need to make adjustments you can multiply this global variable to make it faster or slower, e.g.
Code:
skeleton_animation_mix("anim1", "anim2", global.spine_default_blend * 1.125); // faster
 

rIKmAN

Member
Not sure this is the right forum section to post in but i need some help with skeleton_animation_mix and spine. I have say 100+ animations and the majority of them need to blend into each other, so in the create event i have about a million lines of skeleton_animation_mix("animation1", "animation2", 0.5);

Is there any way through code i could blend every animation on a skeleton to a default 0.5 and then just manually change the rest that need something specific?
@Phil Strahl's method of using a global to control the default mix amount is good practice, but it doesn't remove the need for you to list out every combination of your 100 anims in the Create Event in order to set the mix amount using skeleton_animation_mix().

I'd still use the global to store the default mix amount, but would run through the animations and set every combination using a small for loop, you can then change specific mixes and tweak them as needed to values other than the default.

There's a small check to make sure an animation isn't mixed with itself and each mix is printed to the console for you to see - don't forget to add your own skeleton sprite name instead of <YOUR SPRITE NAME>.
Code:
global.spine_default_mix = 0.5;

anim_list = ds_list_create();
skeleton_animation_list(<YOUR SPRITE NAME>, anim_list);

for (var anim1 = 0; anim1 < ds_list_size(anim_list); ++anim1)
{
    for (var anim2 = 0; anim2 < ds_list_size(anim_list); ++anim2)
    {
        if(anim1 != anim2)
        {
            skeleton_animation_mix(anim1, anim2, global.spine_default_mix);
            show_debug_message(anim_list[| anim1] + " :: " + anim_list[| anim2]);
        }
    }
}
 

asollazzo

Member
Good idea with using the global for the mix value. And that code to run through all the animations works spot on, though i did have to change the animation mix line slighty to get the animation to actually mix (it was just outputting the debug messages before).
Code:
skeleton_animation_mix(anim_list[| anim1], anim_list[| anim2], global.spine_default_mix);
Thanks guys :)
 

rIKmAN

Member
Good idea with using the global for the mix value. And that code to run through all the animations works spot on, though i did have to change the animation mix line slighty to get the animation to actually mix (it was just outputting the debug messages before).
Code:
skeleton_animation_mix(anim_list[| anim1], anim_list[| anim2], global.spine_default_mix);
Thanks guys :)
Ah yeah good catch - it was written when not at my computer so the code was from memory and I forgot it was a list - even though I access the list in the line below haha!

I'm not gonna edit my post as I want to leave it as an example of how new users should use their own initiative on top of the help they get to get things working themselves. Good job! :)
 

asollazzo

Member
Ah yeah good catch - it was written when not at my computer so the code was from memory and I forgot it was a list - even though I access the list in the line below haha!

I'm not gonna edit my post as I want to leave it as an example of how new users should use their own initiative on top of the help they get to get things working themselves. Good job! :)
So ive run into a slight snag, not really related to my first issue but didnt want to make a new thread just for it, but is it possible to draw a skewed shadow based off a spine skeleton sprite ? All the usual methods i know of dont seem to support skeleton sprites at all.
 

rIKmAN

Member
So ive run into a slight snag, not really related to my first issue but didnt want to make a new thread just for it, but is it possible to draw a skewed shadow based off a spine skeleton sprite ? All the usual methods i know of dont seem to support skeleton sprites at all.
What methods have you tried that don't support Spine skeletons?
 

asollazzo

Member
What methods have you tried that don't support Spine skeletons?
Not on my pc at the moment but I think they involved draw_sprite_pos or vertex co ords which apparently don’t support spine sprites. Also tried to draw the skeleton to a surface but drawing the skeleton sprite twice was somehow increasing the speed that the skeleton sprite played at (that one was probably my bad code)
 

rIKmAN

Member
Not on my pc at the moment but I think they involved draw_sprite_pos or vertex co ords which apparently don’t support spine sprites. Also tried to draw the skeleton to a surface but drawing the skeleton sprite twice was somehow increasing the speed that the skeleton sprite played at (that one was probably my bad code)
Yeah my suggestion would have been to draw it to a surface, not sure why it would increase the playback speed though.
I did this in my Spine extension and didn't experience anything like that so I would have to assume it was something else in your code causing that.

The way I'd probably go for this (without testing) would be to draw the skeleton to a surface, then use surface_get_texture() to grab that as a texture and then draw a textured primitive using that texture.

If you wanted to use regular sprite functions you can also turn the surface into a sprite and use something like draw_sprite_ext_skew by YellowAfterlife, but with the amount of frames needed to be matched I'm not sure that would be fast enough and it would be pretty inefficient as each sprite would be put on it's own texture page when you added it from the surface. You could manage it by adding/removing them in realtime but you'd have to test that to see how it performed.

The other way would be to "prebake" them into regular spritesheets, but again this will depend on the amount of animations and frames in your skeleton that would need matching as to whether it would be a feasible solution or not.
 

asollazzo

Member
Yeah my suggestion would have been to draw it to a surface, not sure why it would increase the playback speed though.
I did this in my Spine extension and didn't experience anything like that so I would have to assume it was something else in your code causing that.

The way I'd probably go for this (without testing) would be to draw the skeleton to a surface, then use surface_get_texture() to grab that as a texture and then draw a textured primitive using that texture.

If you wanted to use regular sprite functions you can also turn the surface into a sprite and use something like draw_sprite_ext_skew by YellowAfterlife, but with the amount of frames needed to be matched I'm not sure that would be fast enough and it would be pretty inefficient as each sprite would be put on it's own texture page when you added it from the surface. You could manage it by adding/removing them in realtime but you'd have to test that to see how it performed.

The other way would be to "prebake" them into regular spritesheets, but again this will depend on the amount of animations and frames in your skeleton that would need matching as to whether it would be a feasible solution or not.
Thanks man, ended up getting it working pretty well using surface_get_texture and drawing a textured primitive, but i think i will probably go back to my old static circle type shadow since the weird perspective i have the characters at doesnt really seem to jive with the dynamic shadow (mainly when something goes below where feet should be, as you can see below).

shadow.gif
 

rIKmAN

Member
Thanks man, ended up getting it working pretty well using surface_get_texture and drawing a textured primitive, but i think i will probably go back to my old static circle type shadow since the weird perspective i have the characters at doesnt really seem to jive with the dynamic shadow (mainly when something goes below where feet should be, as you can see below).

View attachment 25357
Hey no worries, that actually looks pretty good - nice job!

What what you'd need to do is make the shadow skeleton thrust upwards when the character skeleton was thrusting downwards, so you'd be playing the opposite anim on the shadow so that the shadows appeared to match up. It wouldn't need to be a pixel perfect match just close enough to not stick out as "wrong".

I'm not sure if you're using an IK target for the cursor or just rotating bones but you could try just changing the rotation angles on the shadow skeleton and see how that looks. You might need to tweak it a little in terms of the posture, rotation angle of the back / hips etc.

It'd be worth playing with I think just to see how it looked, but it depends on how many animation you have that might become cases that you need to create seperate "matching" shadow anims for and whether you think that would be worth it over just having the circle type shadow.
 
Last edited:

asollazzo

Member
Hey no worries, that actually looks pretty good - nice job!

What what you'd need to do is make the shadow skeleton thrust upwards when the character skeleton was thrusting downwards, so you'd be playing the opposite anim on the shadow so that the shadows appeared to match up. It wouldn't need to be a pixel perfect match just close enough to not stick out as "wrong".

I'm not sure if you're using an IK target for the cursor or just rotating bones but you could try just changing the rotation angles on the shadow skeleton and see how that looks. You might need to tweak it a little in terms of the posture, rotation angle of the back / hips etc.

It'd be worth playing with I think just to see how it looked, but it depends on how many animation you have that might become cases that you need to create seperate "matching" shadow anims for and whether you think that would be worth it over just having the circle type shadow.
Hmm at the moment im actually just redrawing the normal skeleton via the method i said rather than actually having a whole separate skeleton just for the shadow. For my aiming im using IK and some transform constraints set through spine and not really changing the skeleton manually through GMS. Would running a separate skeleton just for the shadow add much extra lag ?
 

rIKmAN

Member
Hmm at the moment im actually just redrawing the normal skeleton via the method i said rather than actually having a whole separate skeleton just for the shadow. For my aiming im using IK and some transform constraints set through spine and not really changing the skeleton manually through GMS. Would running a separate skeleton just for the shadow add much extra lag ?
Shouldn't do but it's largely dependant on the the other game code, the skeleton complexity, hardware it's running on etc so you'd be best off profiling both ways to see how it affects performance.

I had an very overly complex skeleton in the demo room of my Spine extension as I was testing performance (~20 bounding boxes, several hundred bounding box verts in total) and had 10-12 of them running in the same room all with individual bounding box collisions, slot colouring etc (this is before it was natively added to GMS2 and doing it with my extension) and I was still getting around 600+fps - but I have a good rig.

With a single "normal" skeleton you'd be fine I think, but as I say best thing to do is profile it and see what you think.
 
Last edited:
Top