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:
Apparently due to floating-point rounding. I have to write this way (but there may be problems because of this):
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:
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)
Code:
if(frameAttack>=framesAttack-1.1)
Therefore, I have two questions:
- How to correctly determine the completion of the playback of a certain animation?
- How to make a smooth transition, if you want to apply several animations to one character at the same time, then cancel one?