MrDreamy

Hello guys, I can't seem to find a way how to mix animations on different tracks. I have running and idle animations on the first track that mix fine when i switch between them on the first track. The problem starts when I play a spellcasting animation on the second track. Hands of my character just teleport to the starting positions of the animation and don't mix with the other animation on the first track. I tried to find a way to make it work, but it doesn't look like there is a method for this in my runtime. The closest thing I got to work is alpha, but that's all, no mixed transitions. I would be very thankful for your help.
MrDreamy
Mensajes: 5

Nate

Have you tried it in the Preview view?
Preview - Spine User Guide
Avatar de Usuario
Nate

Nate
Mensajes: 8420

MrDreamy

Yes I did, in the editor it works flawlessly, but I can't find the track mixing in the runtime
MrDreamy
Mensajes: 5

Pharan

Did you mean you're not aware of this?
AnimationState state;
state.SetAnimation(0, "walk", true); // Play the walking animation on track 0.
state.SetAnimation(1, "cast spell", true); // Play the "cast spell" animation on track 1.
Avatar de Usuario
Pharan

Pharan
Mensajes: 5335

MrDreamy

I have already used similar code where the mixing did not work. In the tutorial the track entry.MixDuration is set to 0.5f, which I did set after setting the animation. But I found the solution. The problem was that SetEmptyAnimation method sets the track to null, which makes next SetAnimation mixing impossible - thus the animation jumps immediately. after removing the line entry.trackEnd = mixDuration in SetEmptyAnimation in spine runtime solved the problem. Anyway thanks for your quick responses :) I hope this helps other people with the same problem. TLDR - there always needs to be an empty animation in a track for mixing to work, which there was not because SetEmptyAnimation in base runtime nullifies the track
MrDreamy
Mensajes: 5

Nate

You shouldn't need to modify the runtime. Relevant docs are here:
AnimationState setEmptyAnimation
And also here:
Applying Animations - Spine Runtimes Guide: Empty animations
You mentioned you found this second link, maybe you hadn't seen the first.

Code might look like:
AnimationState state;

// "walk" animation on track 0.
state.setAnimation(0, "walk", true);

// Empty animation on track 1, so we have something to mix from.
state.setEmptyAnimation(1, 0);
// The 0 in the line above is mix duration, useful when mixing out, eg from an animation to nothing.
// We don't need that though, as we are mixing in.

// Mix from empty to "cast spell".
TrackEntry entry = state.addAnimation(1, "cast spell", true, 0);

// Set how long it takes to mix from empty to "cast spell".
entry.mixDuration = 0.25f;
Avatar de Usuario
Nate

Nate
Mensajes: 8420

MrDreamy

The example you posted does not work in monogame runtime, because setEmptyAnimation disposes the track 1 on the "entry.trackEnd = mixDuration". when the track 1 is null, mixing into it by setAnimation does not work. I even found comment in the runtime quoting: // Don't mix from an entry that was never applied. Which means null track. So the mix does not happen.
MrDreamy
Mensajes: 5

Nate

It does work in spine-libgdx, the reference implementation. If it doesn't work in spine-monogame then it is a bug. You would get the behavior you describe if you are calling setEmptyAnimation and then setAnimation. You need to call setEmptyAnimation and then addAnimation.
Avatar de Usuario
Nate

Nate
Mensajes: 8420


Volver a Runtimes