Exemplo n.º 1
0
    void HandleInput()
    {
        _normalizedHorizontalSpeed = Input.GetAxis("Horizontal");

        if ((Input.GetButton("Left") && _isFacingRight && !Input.GetButton("Right")) ||
            (Input.GetButton("Right") && !_isFacingRight && !Input.GetButton("Left")))
        {
            Flip();
        }

        if (AnticipateJump && Input.GetButtonDown("Jump"))
        {
            JumpWhenGrounded = true;
        }

        if ((Input.GetButtonDown("Jump") && IsGrounded && !Jumpping) || (JumpWhenGrounded && IsGrounded))
        {
            Jump(JumpMagnitude);
        }

        else if (CanWallJump && Input.GetButtonDown("Jump"))
        {
            JumpOffWall(WallJumpForce);
        }

        if (Jumpping && !Input.GetButton("Jump"))
        {
            _controller.AddVerticalForce(-JumpInterruptStrength);
        }

        _controller.State.DropThroughPlatform = Input.GetButton("Down");
    }