• Unity
  • TrackEntry.Alpha not doing anything

  • Изменено
Related Discussions
...
  • Изменено

Hi there,

with the following code in place I can still see the layered animation playing. How come? Does Alpha only work when the base animation has keyframes for the bones in question?

_skeleton.AnimationState.SetAnimation(0, "animation_1", true);
var entry = _skeleton.AnimationState.SetAnimation(2, "animation_2", true);
entry.Alpha = 0;

You can still see which animation playing? If animation_1 then that's expected. See TrackEntry alpha. When applying an animation the alpha controls the mix between the current pose (usually from a lower track) and the animation pose. 1 gives you the animation pose. 0 gives you the current pose. Between 0 and 1 gives you a mix between the current pose and animation pose.

You can change the alpha over time to mix from one animation to another. This is especially useful with additive animations, for example to mix in some of various facial expressions, or to limp more and more as a character takes damage.

Nate написал

If animation_1 then that's expected

I am talking about animation_2.
I think I know what's going on though. The only thing that is happening in that animation is a sprite change. Is it possible to ignore it at below Alpha .5f or some other way to effect it?

Ah, I see. Slot attachment visibility keys have an instant effect, so don't get mixed by TrackEntry alpha. There is TrackEntry attachmentThreshold, but it determines if attachment changes happen when an animation is mixing out using mixDuration, so doesn't help your situation.

Maybe it would be better not to use alpha 0 and to instead not apply your animation at all?

Thanks Nate,
we actually went with playing the animation when needed. Case closed

Cool, thanks for following up! It's probably for the best, since applying an animation with zero alpha still has the runtime doing a lot of work.