How to smoothly change position

In my game I want the camera to smoothly move to a certain position

	float posY = Mathf.SmoothDamp(transform.position.y, player.transform.position.y + distToPlayer, ref     velocity.y, smoothTimeY);

		if(Input.GetMouseButton(0)|| player.transform.position.y > transform.position.y -2.6){
			transform.position = new Vector3(transform.position.x, posY, transform.position.z);
		}

In my script (attatched to camera), when the player position goes beyond the camera’s the camera is meant to begin following it (script is in a fixed update), However the transition of the camera moving to follow the player is static and it just jumps to it. Is there a way I can make it seem smooth. Thanks

Instead of saying

transform.position = new Vector3(

Try:

transform.position = Vector3.Lerp(