Exemple #1
0
        /************************************************************************************************************************/

        protected override void PlayMove()
        {
            // 我们将播放Walk或Run动画.

            // 我们需要知道哪些动画我们正在尝试播放,哪些是其它的.
            AnimationClip playAnimation, otherAnimation;

            if (Input.GetButton("Fire3"))// Left Shift 默认按键
            {
                playAnimation  = _Run;
                otherAnimation = Walk;
            }
            else
            {
                playAnimation  = Walk;
                otherAnimation = _Run;
            }

            // 播放我们想要的那个.
            var playState = Animancer.Play(playAnimation, 0.25f);

            // 如果另一个动画仍在淡出,调整它们的归一化时间,以确保它们在播放周期中保持相同的相对进展.
            var otherState = Animancer.States[otherAnimation];

            if (otherState != null && otherState.IsPlaying)
            {
                playState.NormalizedTime = otherState.NormalizedTime;
            }
        }
Exemple #2
0
        /************************************************************************************************************************/

        protected override void PlayMove()
        {
            // We will play either the Walk or Run animation.

            // We need to know which animation we are trying to play and which is the other one.
            AnimationClip playAnimation, otherAnimation;

            if (Input.GetButton("Fire3"))// Left Shift by default.
            {
                playAnimation  = _Run;
                otherAnimation = Walk;
            }
            else
            {
                playAnimation  = Walk;
                otherAnimation = _Run;
            }

            // Play the one we want.
            var playState = Animancer.Play(playAnimation, 0.25f);

            // If the other one is still fading out, align their NormalizedTime to ensure they stay at the same
            // relative progress through their walk cycle.
            if (Animancer.States.TryGet(otherAnimation, out var otherState) &&
                otherState.IsPlaying)
            {
                playState.NormalizedTime = otherState.NormalizedTime;
            }
        }