Character Controller Movement Jittery?

Hi all! Can someone tell me why my character controller is jittery when moving. This function handles the basic movement for the character, it’s being called from Update.
Control.cs

void UpdateMoveDirection(){                                                           
        Vector3 forward = Camera.main.transform.TransformDirection(Vector3.forward);       
        forward.y = 0;                                                                           
        forward = forward.normalized;                                                           
        Vector3 right = new Vector3(forward.z, 0, -forward.x);                               
        float vertical = Input.GetAxis("Vertical");                                       
        float horizontal = Input.GetAxis("Horizontal");   


        if(controller.isGrounded){ //If the controller is on the ground, move absolutely 
            v = vertical;
            h = horizontal;
        }                   
        else{ //Else, we move smothly in air
            v = Mathf.Lerp(v, vertical, Time.deltaTime * motionSmoothing);
            h = Mathf.Lerp(h, horizontal, Time.deltaTime * motionSmoothing);
        }

        Vector3 targetDirection = h * right + v * forward;   
        targetDirection *= moveSpeed;

        moveDirection.x = targetDirection.x;                                                   
        moveDirection.z = targetDirection.z; 

        if(targetDirection != Vector3.zero && canMove){ //We smoothly rotate here if we canMove
            Quaternion newRotation = Quaternion.LookRotation(targetDirection);
            transform.rotation = Quaternion.Slerp(transform.rotation, newRotation, Time.deltaTime * rotationSmoothing);
        }

        if(canMove)                                                                   
            controller.Move(moveDirection * Time.deltaTime);

        if(controller.collisionFlags == CollisionFlags.Above)
            moveDirection.y = -10.4f; //If we hit or heads, we stop moving upwards

        if(moveSpeed >= maxMoveSpeed) //Limit our moveSpeed
            moveSpeed = maxMoveSpeed;
    }

Please let me know if you have any questions. Thank you!

I see that you’re using Time.deltaTime (multiplied by what I assume is an inspector variable) in your Lerp calls. Time.deltaTime is not constant (it fluctuates between small values depending on how long the previous frame took to render), which means that if you set motionSmoothing to 1, you’re setting the t value of lerp to be, at about 60fps, around 0.016 (1/60) every frame (but it probably jumps around). So why is this bad? Because all Lerp(a, b, t) does is return a value t percent between a and b (where 0 < t < 1). So you’re basically just moving yourself t% closer to your target each frame, except x is not constant, which creates the jitter. I wrote a tutorial on lerp if you want to read more.

What are you attempting to do? Do you want the character to feel “floaty” in the air, having less control (slow acceleration/deceleration).

Yes, I’m trying to have the player have less control in the air. The Lerp is supposed to smoothly send the “numbers” from the horizontal and vertical Input floats to the h and v float variables, giving the player a simulated smooth motion when in the air. There may be some jitters in the air that I haven’t noticed, but as far as I could tell, the problem was with the jitters while grounded.