I am trying to play an animation reversed (from the end to the begining) from Unity.
I'm pretty sure it is possible, as I read this part of the doc:
Applying animations

Animation apply overwrites the current pose of a Skeleton with the pose from the animation at a specific time:
Skeleton skeleton = new Skeleton(skeletonData);
Animation walkAnimation = skeletonData.findAnimation("walk");
float animationTime = 0;
function render (float delta) {
animationTime += delta;
walkAnimation.apply(skeleton, animationTime, true); * true is for loop
In this example, the animationTime is incremented by the delta time since the last render. Next, apply is called which changes the bones and slots that have keyframes in the animation. If bones are changed, only the local SRT is changed. Next, updateWorldTransform is called to compute the world SRT for each bone. Lastly, the skeleton can now be rendered, which uses the world SRT for each bone.

The time passed to the apply method controls the speed of the animation. It can be decremented to play the animation backward. An animation is complete when the time is greater than the animation duration.

Because the animation time is not stored inside the animation, the animation is stateless and can be used for any number of skeleton instances.
However, so far I have been using the animation state, with setAnimation() and addAnimation() and I never worried about updating the time and calling apply() and updateWorldTransform(). Is it something that is required? Why does it seems to work without it?
  • Mesajlar: 6


The documentation you read is meant for low-level use (mostly for how to modify the Spine runtime for your project's needs)
If you're just starting out with Spine-Unity, this documentation is more appropriate:

That said, playing animations backwards is not supported by AnimationState. It always assumes that time moves forwards and that's how it tracks when to play next animations in the queue.

So for playing backwards, you either need to manually Apply the animation yourself, backwards; partly mimicking what AnimationState does for you, at least during those periods of time when you need it.
Or you need to modify AnimationState to include that specialized behavior in its system.
Kullanıcı avatarı
  • Mesajlar: 5366

Dön Unity