Ejemplo n.º 1
0
        private void OnFootMovement(FootMovement movement)
        {
            switch (movement)
            {
            case FootMovement.LeftUp:
            case FootMovement.LeftDown:
            case FootMovement.LeftNone:
                FootLeftMovement = movement;
                break;

            case FootMovement.RightDown:
            case FootMovement.RightUp:
            case FootMovement.RightNone:
                FootRightMovement = movement;
                break;
            }
        }
Ejemplo n.º 2
0
            public void UpdateStepProgress(float deltaTime, float stepSpeed, float shuffleDistance, FootMovement forwardMovement, FootMovement backwardMovement)
            {
                if (!this.IsStepInProgress)
                {
                    return;
                }

                lerp += deltaTime * stepSpeed;

                float strideSignedSize = worldPosNext.x - worldPosPrev.x;
                float strideSign       = Mathf.Sign(strideSignedSize);
                float strideSize       = (Mathf.Abs(strideSignedSize));

                var movement = strideSign > 0 ? forwardMovement : backwardMovement;

                worldPos.x = Mathf.Lerp(worldPosPrev.x, worldPosNext.x, movement.xMoveCurve.Evaluate(lerp));
                float groundLevel = Mathf.Lerp(worldPosPrev.y, worldPosNext.y, lerp);

                if (strideSize > shuffleDistance)
                {
                    float strideSizeFootRaise = Mathf.Clamp((strideSize * 0.5f), 1f, 2f);
                    worldPos.y = groundLevel + (movement.raiseCurve.Evaluate(lerp) * movement.maxRaise * strideSizeFootRaise);
                }
                else
                {
                    lerp      += Time.deltaTime;
                    worldPos.y = groundLevel;
                }

                if (lerp > 1f)
                {
                    lerp = 1f;
                }
            }
Ejemplo n.º 3
0
            public static float GetNewDisplacement(float otherLegDisplacementFromCenter, float comfyDistance, float minimumFootDistanceX, float maxNewStepDisplacement, FootMovement forwardMovement, FootMovement backwardMovement)
            {
                var   movement         = Mathf.Sign(otherLegDisplacementFromCenter) < 0 ? forwardMovement : backwardMovement;
                float randomCompensate = Random.Range(movement.minDistanceCompensate, movement.maxDistanceCompensate);

                float newDisplacement = (otherLegDisplacementFromCenter * randomCompensate);

                if (Mathf.Abs(newDisplacement) > maxNewStepDisplacement || Mathf.Abs(otherLegDisplacementFromCenter) < minimumFootDistanceX)
                {
                    newDisplacement = comfyDistance * Mathf.Sign(newDisplacement) * randomCompensate;
                }

                return(newDisplacement);
            }
Ejemplo n.º 4
0
 private void OnFootMovement(FootMovement movement)
 {
     switch (movement)
     {
         case FootMovement.LeftUp:
         case FootMovement.LeftDown:
         case FootMovement.LeftNone:
             FootLeftMovement = movement;
             break;
         case FootMovement.RightDown:
         case FootMovement.RightUp:
         case FootMovement.RightNone:
             FootRightMovement = movement;
             break;
     }
 }