- Editado
SkeletonViewer with 3.5 AnimationState
The beta version of the Skeleton Viewer has been updated with our efforts to improve AnimationState as well as some UI improvements. You can see everything that what we've done to AnimationState in issue 621. To try it you'll need to export your projects with Spine 3.5-beta.
Probably the most important AnimationState improvement is: When a new animation is played that doesn't have keys for something that the old animation keyed, the unkeyed parts of the skeleton are mixed back to the setup pose. This removes the need to key the entire world on frame zero of every animation! We'll likely include something in the editor to clean up unnecessary keys.
Another big change is how rotate timelines are mixed. To mix rotation between two animations, you have two angles and a percentage. There are two possible ways to mix these angles, the long way around and the short way, so Spine chooses the short way. However, mixing happens over time, so the angle change over time. If the angles change in such a way that the other direction becomes the shortest way around, then the mixed rotation flips to the other side. This was extremely noticeable, so now it is fixed. AnimationState keeps track of rotation directions and does the right thing. Here's a tool we built while developing the solution, it probably doesn't mean a lot to you but damn it looks super fancy (the green bone is mixed 0-1 between red and blue while red and blue spin around):
Image removed due to the lack of support for HTTPS. | Show Anyway
You can now mix to/from the setup pose and you can also mix an animation on a higher track in/out. This is accomplished by using an "empty" animation which has no timelines, solely to control the mix time. This is a common need, so two new convenience methods have been added: addEmptyAnimation
and setEmptyAnimation
. Here's an example which will mix from the setup pose to the run animation over 1 second, then 3 seconds later it mixes back to the setup pose over 1.3 seconds:
state.setEmptyAnimation(track, 0); // 0 is the mix time to mix to the setup pose.
TrackEntry entry = state.addAnimation(track, "run", true, 0); // Like always, true is loop, 0 is delay.
entry.setMixDuration(1); // Mix from the setup pose to "run" over 1 second.
state.addEmptyAnimation(track, 1.3, 3); // 1.3 is the mix time to mix to the setup pose, 3 is delay.
The exact same code also works to mix an animation in and out on a higher track. Skeleton Viewer now uses empty animations and lets you choose which track when playing animations, so you can better experiment:
Image removed due to the lack of support for HTTPS. | Show Anyway
AnimationState can now mix from multiple animations. Eg, if you are playing A then mix to B, but during that mix you mix to C, it used to snap to A or B (whichever the mix was closest to), then mix to C. The snapping was ugly, so now it continues mixing A to B and then mixes the result to C. You can mix any number of animations like this. Skeleton Viewer shows the mixes for each track:
Image removed due to the lack of support for HTTPS. | Show Anyway
There are many other improvements, such as ensuring the events are always fired in a deterministic order and that code in an event listener can never ruin the internal state of the AnimationState. See issue 621 for the full list of things that were improved. There is even more though, eg TrackEntry has seen a lot of love and has more knobs to customize playback. Eg, you can set a start and end time to be used for looping, you can set the mix time on the entry without needing to use AnimationStateData, and more.
The new AnimationState is already fully documented. This is likely the start of a Spine Runtimes User Guide, similar to the guide the editor has.
Before you ask (if you ask, we'll know you didn't read the whole post! :p), the runtimes are already being updated to 3.5. In fact, ALL the runtimes are already updated to work with 3.5 exports in the dev branch (spine-csharp is currently in its own branch), it's just the new AnimationState improvements that aren't in all runtimes yet. Once that is done, which will be soon, we'll move on to 3.6. If you're curious what's in store for 3.6, check out the 3.6 milestone waffle.
OMG!, amazing guys!, really amazing.
I was reading what is coming up when you finish v3.6 and it has SO MANY features!!! animation mixing, clipping/masking (I need it with urgency), multiple skins at once!!! this is by far the best feature I've read until now because my character has a mix of theme + levels of armor that I don't know how to organize yet, don't know if to sort skins by level or by theme of armor and that feature is going to help A LOT!.
Amazing, keep the good work, this is by far the best animation tool I've ever used or have knowledgment of!
This is a massive help to my workflow. I'm so glad animationstate has been given another pass. Thank you for your hard work!
Quick update (you can follow progress here [runtimes] Port AnimationState changes to runtimes · #732)
The Java, C#, AS3 and TypeScript based runtimes are now all up to date with the AnimationState changes. To test, export using the latest Spine beta version, and use the code from the dev branch on Github.
I'm now working on the Lua and C based runtimes, I hope to be done with those next monday (probably more like tuesday).