Gravity not working correctly

I changed some of my code to make it where the character looks at and moves based on mouse movement, but now my gravity doesn’t, and jumping doesn’t work anymore. I think it has something to do with the velocities being equal to the camera, but I don’t know how to fix it without making the character rotation not work anymore.

CharacterController controller;
Vector3 movementDirection;
bool isGrounded;

public float speed = 5f;
public float gravity = 9.8f;
public float jump = 5f;

public float turnSmoothTime = .5f;
public float turnSmoothVelocity;

public Camera camera;




private void Start()
{
    controller = GetComponent<CharacterController>();
}

private void Update()
{
    Movement();
    Gravity();
    controller.Move(movementDirection * speed * Time.deltaTime);

    
}

public void Movement()
{
    float horizontalMovement;
    float verticalMovement;

    horizontalMovement = Input.GetAxisRaw("Horizontal");
    verticalMovement = Input.GetAxisRaw("Vertical");

    controller.transform.Rotate(0, Input.GetAxis("Mouse X"), 0);

    Vector3 movementInput = Quaternion.Euler(0, camera.transform.eulerAngles.y, 0) * new Vector3(horizontalMovement, controller.velocity.y, verticalMovement);
    movementDirection = movementInput.normalized;

    
    
    if(Input.GetButtonDown("Jump"))
    {
        movementDirection.y = jump;
        
    }

    Debug.Log(movementDirection);
}

public void Gravity()
{
    if (controller.isGrounded)
    {
        movementDirection.y -= -.5f * Time.deltaTime;

    }
    else movementDirection.y -= gravity * Time.deltaTime;
     
}

Try using GetComponent<Rigidbody>().AddForce(gravity), or Rigidbody2D if you’re in 2D

Edit: Or just use the Rigidbody gravity?

controller.transform.Rotate(0, Input.GetAxis(“Mouse X”), 0); is always set x and z values to zero and in movement input some zeros are multiplied.

Movement direction is a rotaton, jump is not working because jump used as position not rotation.

and if you fix it “movementDirection.y = jump” is just redirects the character to the y position you typed try movementDirection += gravityValue * Time.deltaTime; and gravityValue must be negative.
Add OnGround bool, equal this bool with characterControllers grounded property, jump is useable only when character is grounded add an if condition for this.