Paragonyx

Hello,

Here is my scenario:

I currently have a run animation and a shooting animation. The shoot animation only animates the arm for a recoil effect, not just translates the arm back. Almost like a whiplash recoil. I'm playing the run animation on track 0, then playing the shoot animation on track 1.

Is there a way to get the shoot animation to crossfade back into the run animation, specifically the arm? Right now it just snaps back to position and continues the run animation after the shooting animation is done.
Avatar
Paragonyx
  • Postovi: 5

Pharan

Are you using SkeletonAnimator(Mecanim) or SkeletonAnimation?

Rule of thumb is that if you want anything to crossfade/blend/mix: the from-animation and to-animation need to have keys for those items.

Specifically, if the from-animation has rotation keys for the arm, the to-animation also needs rotation keys for the arm.
Make sure they exist both at the very start and the very end of each animation.
Avatar
Pharan
  • Postovi: 5366

Paragonyx

We're using SkeletonAnimation, not mecanim.

Right, I understand what you're saying in regards to having keys on the start and end of the animations. My shoot animation has translation/rotation keys on the arm at the start and at the end, so does my run animation.

I play my running animation on track 0 with looping then play my shoot animation on track 1 without loop then when my shoot animation is done, the arm snaps back to the arm animation within the running instead of crossfading into it.

Is this because the shoot animation is not looping? I would think that it should mix just fine. I also noticed this happens if I play an animation once, it'll be stuck on the last frame once its done and then I try to play another animation a few seconds later it just pops to the next animation instead of blending into it. Hopefully that makes sense, could this be the same issue or are we just missing something here?
Avatar
Paragonyx
  • Postovi: 5

Pharan

No, it has nothing to do with looping.
But Spine doesn't crossfade animations in different tracks. It only crossfades animations on the same track. And it can only crossfade between a currently playing animation and another animation you want to play next. Animations won't fade in while the track are empty. If you always want crossfading to happen, you should always have an animation playing.

On the other hand, Animations playing on different tracks only override each other. There's no crossfading going on there at all.

There are a lot of assumptions that Spine doesn't make because it's supposed to be flexible and programmatic-animation friendly. The main assumption it has it probably "the user could be trying to do anything, so don't do anything unless it's specified."
One of the most basic things you have to realize is that, when it plays an animation, it just applies the keys defined by the animation (changing the transform properties of bones like rotation, scale, position, slot images and nothing more). Once an animation is done playing, it won't do anything you don't tell it to. If you don't tell it to go back to its setup pose, it won't. If it doesn't have enough information, it won't try to guess what you want.
It's a very programming-y paradigm behind it. What you gain from that is flexibility required by complex animation systems, but you may lose a lot of convenience like the ones you're looking for. (Or in this case, as in many cases, it does sound like something that could be added in. But that's not really my call. There's always the issue of keeping the base implementation simple enough to maintain while providing easy access to the most common cases. Just my interpretation.)

The way I see it, you have at least two options to solve your problem.

(a)
We're only talking about the behavior of the built-in Spine.AnimationState.
Spine is source-available and modifiable so if you need something specific, read the docs and study how AnimationState works and you can make it work the way you want. You can fade-out the arm-shooting animation after it plays. That's possible to do if you code it yourself and make it do whatever you need it to do.

(b)
You can stick with the built-in AnimationState that SkeletonAnimation has.
You may have to make a new animation that the arm shoot animation can mix with on track 1.
You can copy all the arm animation keys from the running animation into a new animation, and also the arm animation keys from any other character animations you want your shooting animation to blend with.
Basically, you'll need a whole set of animations for track 1 so they can crossfade with each other.

But like I said, Spine's pretty flexible and there are likely other ways to get what you want. IK. Programmatic posing. But there's two for you.
Avatar
Pharan
  • Postovi: 5366

Paragonyx

Thanks for the response Pharan.

I was seeing if the Spine API had this behavior out of the box. We already have an animation framework built on top of the API, I will expand AnimationState.
Avatar
Paragonyx
  • Postovi: 5


Natrag na Unity