Restricting camera bounds

I’ve been waiting a week for an answer with nothing else to do so I’ll make it simple.

I have an ortho camera and want to let the user pan without it viewing anything outside of an object in my scene. I’ve been working for a week solid so I’ve tried a lot of things.

Here’s a basic script for clamping up/down to 80 degrees. You can add another clamp for the player rotation for what you want

	camAngle = Mathf.Clamp(camAngle + Input.GetAxisRaw("Mouse Y") * sensitivity, -80f, 80f);

	player.localEulerAngles = new Vector3(0f, player.eulerAngles.y + Input.GetAxisRaw("Mouse X") * sensitivity, 0f);
	cam.localEulerAngles = new Vector3(-camAngle, 0f, 0f);