Keeping a plain/terrain within the view frustrum

You can get rays from the camera at a given spot, so one approach is to cast rays from the camera corners and make sure they hit your terrain, or hit your terrain bounding box.

To ignore screen pixel dimensions and just get the corner rays, this is the API you want:

The nice part is that it doesn’t matter how your camera is set, how your field of view is set, etc., It just works.

You can use this to raycast and hit physics on your ground using:

  • asks “did I hit any collider in the scene?”

If you are truly only interested in hitting one collider and one collider alone, colliders actually have their own Raycast, that only checks them and nobody else:

  • asks “did I hit this particular collider?”

Or alternately, if you prefer to hit a mathematical Plane (completely different from the “Plane” primitive object!), you can use:

  • asks “did I hit this plane?”

When using any of these methods, it is very common to have a proxy GameObject (or GameObjects) to mark a movement boundary slightly smaller than your actual terrain, and to use that smaller piece as the limit. This gives you better control, divorcing presentation from logical checking of camera movement.