예제 #1
0
    /// <summary>
    /// Apply a movement to the character and check if it is grounded.
    /// Here comes all the inertia stuff.
    /// </summary>
    /// <param name="move">Move to apply</param>
    private void ApplyMove(Vector3 move)
    {
        var hits       = _characterController.Move(move * Time.deltaTime);
        var isGrounded = (hits & CollisionFlags.Below) == CollisionFlags.Below;

        if (isGrounded != IsGrounded)
        {
            if (isGrounded)
            {
                _currentLogic.Landed();
            }
            else
            {
                _currentLogic.Falling();
            }
        }
        IsGrounded = isGrounded;

        if ((hits & CollisionFlags.Above) == CollisionFlags.Above)
        {
            move.y = -1f;
        }
        Velocity = move;
    }