Camera restrict movement with Mathf.Clamp - undesirable jump

Hi,
I have restricted movement of the camera in RTS like game with Mathf.Clamp:

Vector3 p = camera.transform.position;
camera.transform.position = new Vector3(Mathf.Clamp(p.x, minBoundX, maxBoundX),
p.y,
Mathf.Clamp(p.z, minBoundZ, maxBoundZ));

But there is rotation (camera.transform.RotateAround(rotationCenter, Vector3.up, GetMouseAxis.x * rotationSpeed / Time.timeScale * Time.deltaTime))
and after rotation there is posibility that camera is out of bounds - it need to be that way, because I don’t want to block rotation.
After this situation, when start move camera, Mathf.Clamp makes “jump” to the min/maxBound.

Could anyone advice any solution to this?

Do not “drive” the camera position directly.

Instead drive a “desired” camera position with the above code, and that position will always be clamped into your range.

Vector3 DesiredPosition;   // set this with your clamp above
const float Snappiness = 5.0f;   // how snappy to make the camera

Then have a separate line that takes that desired position and moves the camera towards it, perhaps even something like:

camera.transform.position = Vector3.Lerp(
         camera.transform.position,
         DesiredPosition,
         Snappiness * Time.deltaTime);