Example #1
0
        /************************************************************************************************************************/

        private void Awake()
        {
            // Instead of only a single animation, we have a different one for each direction we can face.
            // So we get whichever is appropriate for that direction and play it.
            var clip = _Idles.GetClip(_Facing);

            _Animancer.Play(clip);
        }
Example #2
0
        /************************************************************************************************************************/
#if UNITY_EDITOR
        /************************************************************************************************************************/

        /// <summary>[Editor-Only]
        /// Sets the character's starting sprite in Edit Mode so you can see it while working in the scene.
        /// </summary>
        /// <remarks>Called in Edit Mode whenever this script is loaded or a value is changed in the Inspector.</remarks>
        private void OnValidate()
        {
            if (_Idle != null)
            {
                _Idle.GetClip(_Facing).EditModePlay(_Animancer);
            }
        }
Example #3
0
        /************************************************************************************************************************/

        private void Update()
        {
            var input = new Vector2(Input.GetAxisRaw("Horizontal"), Input.GetAxisRaw("Vertical"));

            if (input != Vector2.zero)
            {
                _Facing = input;
                var state = _Animancer.Play(_Walks.GetClip(_Facing));

                // We can still set the Speed of the animation we are playing, exactly the same as we normally would.

                if (Input.GetButton("Fire3"))// Left Shift by default.
                {
                    state.Speed = 2;
                }
                else
                {
                    state.Speed = 1;
                }
            }
            else
            {
                // When we aren't moving, we still remember the direction we are facing so we can continue using the
                // correct idle animation for that direction.
                _Animancer.Play(_Idles.GetClip(_Facing));
            }
        }
Example #4
0
        /************************************************************************************************************************/
#if UNITY_EDITOR
        /************************************************************************************************************************/

        /// <summary>[Editor-Only]
        /// Sets the character's starting sprite in Edit Mode so you can see it while working in the scene.
        /// </summary>
        /// <remarks>Called in Edit Mode whenever this script is loaded or a value is changed in the Inspector.</remarks>
        private void OnValidate()
        {
            if (_Idles != null)
            {
                _Idles.GetClip(_Facing).EditModeSampleAnimation(_Animancer);
            }
        }
        /************************************************************************************************************************/
#if UNITY_EDITOR
        /************************************************************************************************************************/

        /// <summary>[Editor-Only]
        /// Sets the character's starting sprite in Edit Mode so you can see it while working in the scene.
        /// </summary>
        /// <remarks>
        /// Called by the Unity Editor in Edit Mode whenever an instance of this script is loaded or a value is changed
        /// in the Inspector.
        /// </remarks>
        private void OnValidate()
        {
            if (_Idles == null)
            {
                return;
            }

            AnimancerUtilities.EditModePlay(_Animancer, _Idles.GetClip(_Facing), true);
        }
Example #6
0
        /************************************************************************************************************************/

        private void Play(DirectionalAnimationSet animations)
        {
            // Store the current time.
            _MovementSynchronization.StoreTime(_CurrentAnimationSet);

            _CurrentAnimationSet = animations;
            _Animancer.Play(animations.GetClip(_Facing));

            // If the new animation is in the synchronization group, give it the same time the previous animation had.
            _MovementSynchronization.SyncTime(_CurrentAnimationSet);
        }
        /************************************************************************************************************************/

        private void Play(DirectionalAnimationSet animations)
        {
            // 装载每一个单独的动画时, 我们有不同的动画对应每个面朝的方向.
            // 所以我们选择适合那个方向的,然后播放它.

            var clip = animations.GetClip(_Facing);

            _Animancer.Play(clip);

            // 或者我们可以在一行中这样做: _Animancer.Play(animations.GetClip(_Facing));
        }
        /************************************************************************************************************************/

        private void Play(DirectionalAnimationSet animations)
        {
            // Instead of only a single animation, we have a different one for each direction we can face.
            // So we get whichever is appropriate for that direction and play it.

            var clip = animations.GetClip(_Facing);

            _Animancer.Play(clip);

            // Or we could do that in one line:
            // _Animancer.Play(animations.GetClip(_Facing));
        }
Example #9
0
        /************************************************************************************************************************/

        private void Awake()
        {
            _Animancer.Play(_Idle.GetClip(_Facing));
        }
Example #10
0
        /************************************************************************************************************************/

        private void Play(DirectionalAnimationSet animations)
        {
            _CurrentAnimationSet = animations;
            _Animancer.Play(animations.GetClip(_Facing));
        }
Example #11
0
        private void SetIdleAnimation()
        {
            var clip = idles.GetClip(Facing);

            animancer.Play(clip);
        }