コード例 #1
0
        private void InitializeInterpolationFactors()
        {
            directionInterpolationFactors = new InterpolationFactors
            {
                AnimatorValueName          = ValueNameDirectionFactors,
                DiffFactor                 = 0.5f,
                InterpolatingPerFrameValue = 0.02f
            };

            angleInterpolationFactors = new InterpolationFactors
            {
                AnimatorValueName          = ValueNameAngle,
                DiffFactor                 = 2,
                InterpolatingPerFrameValue = 0.02f
            };

            shootingLayerInterpolationFactors = new InterpolationFactors
            {
                AnimatorValueName          = LayerNameShooting,
                InterpolatingPerFrameValue = 0.02f
            };

            handsLayerInterpolationFactors = new InterpolationFactors
            {
                AnimatorValueName          = LayerNameHands,
                InterpolatingPerFrameValue = 0.02f
            };
        }
コード例 #2
0
 private void BeginInterpolation(float end, ref InterpolationFactors factors)
 {
     factors.Begin           = factors.Actual;
     factors.End             = end;
     factors.Interpolant     = 0;
     factors.IsInterpolating = true;
 }
コード例 #3
0
        private void InterpolateLayerWeight(ref InterpolationFactors factors)
        {
            if (factors.IsInterpolating == true)
            {
                factors.Actual = Mathf.Lerp(factors.Begin, factors.End, factors.Interpolant);
                animator.SetLayerWeight(animator.GetLayerIndex(factors.AnimatorValueName), factors.Actual);
                factors.Interpolant += factors.InterpolatingPerFrameValue;
                if (factors.Interpolant > 1 || factors.Interpolant < 0)
                {
                    factors.IsInterpolating = false;
                }
            }

            factors.LastFrame = factors.PresentFrame;
        }
コード例 #4
0
        private void InterpolateAnimation(ref InterpolationFactors factors)
        {
            if (Mathf.Abs(factors.LastFrame - factors.PresentFrame) > factors.DiffFactor)
            {
                BeginInterpolation(factors.PresentFrame, ref factors);
            }

            if (factors.IsInterpolating == true)
            {
                factors.Actual = Mathf.Lerp(factors.Begin, factors.End, factors.Interpolant);
                animator.SetFloat(factors.AnimatorValueName, factors.Actual);
                factors.Interpolant += factors.InterpolatingPerFrameValue;
                if (factors.Interpolant > 1 || factors.Interpolant < 0)
                {
                    factors.IsInterpolating = false;
                }
            }

            factors.LastFrame = factors.PresentFrame;
        }