• 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!
  • Hello [name]! Thanks for joining the GMC. Before making any posts in the Tech Support forum, can we suggest you read the forum rules? These are simple guidelines that we ask you to follow so that you can get the best help possible for your issue.

Question - Code Spine. How to determine when the animation ends?

S

Sergei

Guest
Good day!

Using the Spine software, I created three animations for the character: standing (Stay), going (Walk) and attacking (Attack). In GameMaker Studio 2, I start playing the Stay animation for the default track (skeleton_animation_set()). When I press the navigation keys, I start playing the Walk animation on the same default track. When I release the move key, I start playing the Stay animation on the default track again (for smooth transition use skeleton_animation_mix()). All this was a cyclic animation. There are no problems here. But when I press the attack button, I start playing the Attack animation on track 1 (because I need it so I can attack and move). But the animation turns out to be cyclical and the character can not stop attacking. How correctly will determine that the animation is completed and smoothly go to the main animation?

Now I implemented the definition through the Animation Update event. When an event occurs, I check whether the Attack animation is playing on track 1. If this is the case, then I get the current frame number via the skeleton_animation_get_frame() function for track 1. And also I get how many frames in the Attack animation through the function skeleton_animation_get_frames(). Unfortunately, such a formula for determining the end of the animation does not work:

Code:
if(frameAttack>=framesAttack-1)
Apparently due to floating-point rounding. I have to write this way (but there may be problems because of this):

Code:
if(frameAttack>=framesAttack-1.1)
And if the condition works, then I remove the animation from track 1 via the function skeleton_animation_clear(). But with this approach, you can see how the used pictures from the Attack animation "jerk" go into using the Stay (or Walk) animation. That is, even skeleton_animation_mix() does not help to achieve smoothness when clearing the animation from the track.

Therefore, I have two questions:

  1. How to correctly determine the completion of the playback of a certain animation?
  2. How to make a smooth transition, if you want to apply several animations to one character at the same time, then cancel one?
Thank you for attention!
 

rIKmAN

Member
GMS doesn't play too nice with animations in multiple tracks, but you can get the end of an animation using the Animation End event.

I suggest you read the relevant setup article, blog article and manual section regarding Spine as this is the second thread I've seen of yours where you are asking things that are clearly explained if you just took some time to read the manual.

(If you're wondering, the other thread is the one where you are saying you are using the latest version of Spine v3.5.x and it isn't working, when the setup article clearly states to use v3.4.02)
 
S

Sergei

Guest
GMS doesn't play too nice with animations in multiple tracks, but you can get the end of an animation using the Animation End event.
I need to solve the following problem. I press key movement and I'm starting to play animation movement. t is played on the track by default, that is on track 0. In this motion I press attack and reproduce the animation of attack on track 1. At the same time my character moves and attacks. The movement is cyclical and it is normal. But the attack is carried out cyclically and it is not normal. How can the Animation End event help me here? How do I know in it which of the two animations ended?
 
Top