예제 #1
0
    private float GetStoppedVelocityX(MovementAcceleration movement)
    {
        smoothDampAccelerateVelocity = 0f;
        float currentVelocityX = velocity;
        float velocityX        = Mathf.Sign(currentVelocityX) * Mathf.SmoothDamp(Mathf.Abs(currentVelocityX), 0f, ref smoothDampDecelerateVelocity, movement.timeToStop);

        return(velocityX);
    }
예제 #2
0
 private float GetVelocity(float moveInput, MovementAcceleration movement)
 {
     if (moveInput != 0)
     {
         return(GetMovingVelocityX(moveInput, movement));
     }
     else
     {
         return(GetStoppedVelocityX(movement));
     }
 }
예제 #3
0
    private float GetMovingVelocityX(float moveInput, MovementAcceleration movement)
    {
        smoothDampDecelerateVelocity = 0f;
        float velocityX;

        if (movement.instantDirectionChange)
        {
            velocityX  = Mathf.SmoothDamp(Mathf.Abs(velocity), Mathf.Abs(moveInput) * WorldVelocity, ref smoothDampAccelerateVelocity, movement.timeToFullSpeed);
            velocityX *= Mathf.Sign(moveInput);
        }
        else
        {
            float targetVelocity = moveInput * WorldVelocity;
            velocityX = Mathf.SmoothDamp(velocity, targetVelocity, ref smoothDampAccelerateVelocity, movement.timeToFullSpeed);
        }
        return(velocityX);
    }
예제 #4
0
 private void ReadStats(ScriptableUnit data)
 {
     tileVelocity     = data.TileVelocity;
     groundedMovement = data.GroundedMovement;
     aerialMovement   = data.AerialMovement;
 }