示例#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;
            }
        }
示例#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.CrossFade(playAnimation);

            // If the other one is still fading out, align their NormalizedTime to ensure they stay at the same
            // relative progress through their walk cycle.
            var otherState = Animancer.GetState(otherAnimation);

            if (otherState != null && otherState.IsPlaying)
            {
                playState.NormalizedTime = otherState.NormalizedTime;
            }
        }
示例#3
0
        /************************************************************************************************************************/

        /// <summary>
        /// This method is similar to the "PlayMove" method in <see cref="Locomotion.IdleAndWalkAndRun"/>, but instead
        /// of checking <see cref="Input"/> to determine whether or not to run we are checking if the
        /// <see cref="Creature.Brain"/> says it wants to run.
        /// </summary>
        private void UpdateAnimation()
        {
            float targetBlend;

            if (Creature.Brain.MovementDirection == Vector3.zero)
            {
                targetBlend = 0;
            }
            else if (Creature.Brain.IsRunning)
            {
                targetBlend = 1;
            }
            else
            {
                targetBlend = 0.5f;
            }

            _MoveBlend = Mathf.MoveTowards(_MoveBlend, targetBlend, _Acceleration * Time.deltaTime);
            Animancer.SetFloat("MoveBlend", _MoveBlend);
        }
示例#4
0
        /************************************************************************************************************************/

        private void UpdateAnimation()
        {
            // 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 (Creature.Brain.IsRunning)
            {
                playAnimation  = _Run;
                otherAnimation = _Walk;
            }
            else
            {
                playAnimation  = _Walk;
                otherAnimation = _Run;
            }

            // Play the one we want.
            var playState = Animancer.CrossFade(playAnimation);

            // If the brain wants to move slowly, slow down the animation.
            var speed = Mathf.Min(Creature.Brain.MovementDirection.magnitude, 1);

            playState.Speed = speed;

            // If the other one is still fading out, align their NormalizedTime to ensure they stay at the same
            // relative progress through their walk cycle.
            var otherState = Animancer.GetState(otherAnimation);

            if (otherState != null && otherState.IsPlaying)
            {
                playState.NormalizedTime = otherState.NormalizedTime;
                otherState.Speed         = speed;
            }
        }
示例#5
0
        /************************************************************************************************************************/

        private void OnEnable()
        {
            Animancer.PlayController();
            _MoveBlend = 0;
        }