# How to make camera operate in set boundary?

I’m currently trying to make a game at the moment. I need many shots in the game, with cameras moving all over the place. The only problem is, some of the cameras only move depending on character location, in most cases, the camera will go through walls and go off map. Is there anyway i can use a box to set a boundary where the camera can roam freely? Is there also a way to do it in cycles, i also will need it in making a short. Thank you!
-AaronTrueMachine

You can use a control object, such as an empty, then add a Limit Distance constraint to the camera to keep it within a set distance of the empty, which you could also move.This keeps it inside a sphere of course, not a box. As for keeping it within a box, the only other way would be using Drivers, with a Limits Modifier on the driver to keep the camera within a set distance for each driver associated with its X, Y & Z axes. Just set maximum Y values on the Driver Limits mods to keep the distance.

That’s the only ways I know, maybe someone else has some more ideas…

Cheers, Clock.

Yes, the “Drivers” method works:

Here’s the blend file, just move the empty anywhere you like, the camera stays within a box of 0,0,0 to 5,5,5. Just change the Limits Mods’ Y values to reshape the box.

constrained camera.blend (446 KB)

Don’t forget to enable “Autorun Python Scripts” in User Preferences or the Drivers will not work. :no:

Cheers, Clock.

EDIT:

You can change the Limits Mods’ X values so they only apply over a set range of Frames, this means you can change the boxes by having other mods that work over different frame ranges.

Then I found you can do this with it by adding Copy Rotation constraints to the now two cameras:

constrained camera.blend (466 KB)

Just press Play to see a basic animation. :eyebrowlift:

I now have two “Rooms” signified by the two faces, and can move the Empty - that could be your character for example from room to room so he picks up a different camera, if you render out an animation like this you can switch active camera at the transition between the rooms. - Does this answer the question?

Cheers, Clock.