oshigawa

Hi everyone,

first of all, i'd like to tell you that i've read the documentation, but i'm afraid i simply can't understand how to do what i intend to do because this is all quite new to me.

I was given a task to animate an enemy that has a body and three body parts. I have the skeleton data with the body animation that i put on layer 0, and three animations for layering:

Body part 1 off layer (which contains the body with body part 1 missing, parts 2 and 3 intact)
Body part 2 off layer (which contains the body with body part 2 missing, parts 1 and 3 intact)
Body part 3 off layer (which contains the body with body part 3 missing, parts 1 and 2 intact)

When the first body part gets destroyed, i play the Body part 1 off layer
PlayAnimation (1, "part 1 off layer", true);
When the second body part gets destroyed, i play the Body part 2 off layer on track 2
PlayAnimation (2, "part 2 off layer", true);
When the third body part gets destroyed, i play the Body part 2 off layer
PlayAnimation (3, "part 3 off layer", true);
It all works dandy, the higher layers are hiding the layers below so i get the enemy with one less, two less and without body parts.

BUT, there comes a moment in which i have a problem. The guy regrows the body parts, so i need to do the same in reverse order, make body parts appear one by one. I tried with
animator.AnimationState.ClearTrack(3)
to remove the last track, but that doesn't to the trick. I tried clearing tracks 1, 2 and 3 the playing the animations again, but the guy is still limbless. Of course, it has to be in a manner that the body parts can be layered again.

Any help is appreciated.
oshigawa
  • Сообщения: 2

Nate

It's hard to follow exactly what you are doing, but it sounds like you want to mix each animation to an empty animation. If you use AnimationState clearTrack, the animation will stop being applied and the skeleton state that the animation was changing will stay how it is until something else changes it. Instead, try AnimationState setEmptyAnimation to mix out your animations. Here's the runtimes guide section about it:
Applying Animations - Spine Runtimes Guide: Empty animations
Аватара пользователя
Nate

Nate
  • Сообщения: 9264

oshigawa

Hello Nate,

yes, that's what i am trying to do. That helped me a lot and i achieved exactly what i wanted to do. If someone has a similar issue:
animator.AnimationState.SetEmptyAnimation(int track, float mix);
oshigawa
  • Сообщения: 2


Вернуться в Unity