How to crouch Smoothly

I’ve created crouch function for unity’s fps controller and its working perfectly except one part and that is it’s not smoothly crouching. By smoothly crouching I mean when the player crouches the character controller get smaller and the transition isn’t smooth. Is there a way to smooth the transition between standing and crouching?

Here is my code:

public void Crouch()
    {
        if (isCrouching == false)
        {
            isCrouching = true;
            characterController.height = 0.9f; 
            characterController.center = new Vector3(0, 0.3f, 0);
        }
        else if (isCrouching == true && !Physics.Raycast(transform.position, Vector3.up, 1))
        {
            isCrouching = false;
            // move fps controller a bit up so it doesn't drop through the floor
            FPSController.transform.Translate(0, 0.5f, 0);
            characterController.height = 1.8f;
            characterController.center = new Vector3(0, 0, 0);
        }
    }

A form of linear interpolation is probably what you’re looking for. Check out the answer here.