limit camera movement

my camera is having
transform pos x -10 y 15 z -10
rotation x 30 y 45 z 0
my plane is having
pos x = y = z = 0
w delta = h delta = 0
rotation x 0 y 45 z 0
scale x 10 y 1 z 10

I would like to keep camera in boundries of isometric view of my plane.
The corners are reachable with coords like
camera pos

  • right top corner x 24 y 26 z -35
  • right bottom corner x 15 y 5.33 z -44
  • left top corner x -35 y 26 z 24
  • left bottom corner x -44 y 5.33 z 15

I guess there must be some mathematical formula to say; max(camera_dim) = plane(x,y,z,x_scale,y_scale,z_scale)? Is there any way to use mask or something to do it or maybe some rotating of the plane?

Not a complete solution, but I do this in my current project, which may help.

...
worldSpacePos.x = Mathf.Clamp (worldSpacePos.x, 0, Territory.Geography.WorldBounds.X);
worldSpacePos.z = Mathf.Clamp (worldSpacePos.z, 0, Territory.Geography.WorldBounds.Z);
camera.transform.position = worldSpacePos;

Here I am clamping the X & Z coordinates of the camera to not go outside the world. When I procedurally generate the world, I store the “corners” of the world in an object called Territory.Geography.WorldBounds and use Mathf.Clamp to make sure the camera cannot go outside.

Also, my world “starts” at 0,0,0 and goes “right, up and forward” so negative coordinates are never valid, so I set the lower clamp boundary to zero.