Пример #1
0
        /// <summary>检查当前动画状态</summary>
        /// <param name="stateName">指定的状态名称</param>
        /// <param name="layerName">指定的层级名称</param>
        /// <returns></returns>
        private bool CheckState(EPlayer.FSMState stateName, EPlayer.FSMLayer layerName = EPlayer.FSMLayer.BaseLayer)
        {
            int  layerIndex = animator.GetLayerIndex(layerName.TS());
            bool result     = animator.GetCurrentAnimatorStateInfo(layerIndex).IsName(stateName.TS());

            return(result);
        }
Пример #2
0
        /// <summary>切换FSM层级(使用Lerp平滑切换)</summary>
        /// <remarks>思路:将指定层级的权重平滑增加到1.0/0</remarks>
        /// <param name="layer">改变权重的层级</param>
        /// <param name="lerpTime">插值时间</param>
        private void StateChangeLayer(EPlayer.FSMLayer layer, float lerpTime = 0.4f)
        {
            //使用插值,平缓切换FSM层级
            float curWeight = animator.GetLayerWeight(animator.GetLayerIndex(layer.TS()));

            curWeight = Mathf.Lerp(curWeight, lerpTarget, lerpTime);
            animator.SetLayerWeight(animator.GetLayerIndex(layer.TS()), curWeight);
        }