예제 #1
0
        private void Run(bool isAirborne = false, bool isCrouching = false)
        {
            if (Mathf.Abs(inputMovement.x) > 0.01f)
            {
                GameInput.Hint_Movement?.Invoke();
            }

            if (Mathf.Abs(inputMovement.y) > 0.01f && stateMachine.State == PlayerStates.ClimbLadder)
            {
                GameInput.Hint_LadderClimb?.Invoke();
            }

            float          horVelocityRel = localVelocity.x;
            AnimationCurve accelCurve     = Stats.RunAccelCurve;
            AnimationCurve deaccelCurve   = Stats.RunDeaccelCurve;

            if (isAirborne)
            {
                accelCurve   = Stats.RunAccelAirborneCurve;
                deaccelCurve = Stats.RunDeaccelAirborneCurve;
            }
            else if (isCrouching)
            {
                accelCurve   = Stats.RunCrouchAccelCurve;
                deaccelCurve = Stats.RunCrouchDeaccelCurve;
            }

            if (Mathf.Abs(inputMovement.x) < 0.01f)
            {
                horVelocityRel = deaccelCurve.EvaluateValueByStep(Mathf.Abs(horVelocityRel), Time.fixedDeltaTime, true) * Mathf.Sign(horVelocityRel);
            }
            else
            {
                horVelocityRel = accelCurve.EvaluateValueByStep(horVelocityRel * Mathf.Sign(inputMovement.x), Time.fixedDeltaTime) * Mathf.Sign(inputMovement.x);
            }

            //Debug.Log("MovingPlatformVel: " + playerColliders.movingPlatformVelocity);

            //Debug
            localVelocity.x = horVelocityRel;
            //Debug.Log("MovingPlatformVel: " + playerColliders.movingPlatformVelocity);
        }