Switching Cameras

I’m fairly new to game making, and know very little about blender, so sorry if this is an easy question, but here’s my situation:
Our protagonist needs to be seen from third person view at times, but if preferred by the user, a first person view is necessary. I think the easiest way to accomplish this would be to have to cameras and switch between them, which is where my question originated. How do you switch between two cameras in the game engine. I tried the ‘camera’ actuator, and apparently that isn’t what it does. Help would be appreciated, thanks.

This is the actuator you want. I also made it in python for a different thread before, so say if you’d like to see it.


Ah, okay. I will use the actuator, but it would be nice to see thr python for future referance. Thanks.

Check out this page for the python version:
Scroll down to setCamera.

It’s a great site, worth a bookmark!


The thing about nyquist’s reply is that you still need to use an actuator. With my one you only need a sensor to set it off and a controller.


camera.blend (125 KB)

Okay, thanks to you both.

In Blender, the viewport of the active camera is always enabled. I’d like to clarify, the example you provided shows enabling another camera as opposed to switching active cameras, so now two cameras are enabled in the scene. But it also sets the dimensions of the first viewport to have an area of 0, a clever way of giving the impression of a camera switch. From the user’s perspective, it gives the same result.

A disadvantage to the approach is that you need have references to both cameras and manipulate both cameras to achieve the effect, and the housekeeping tracking which camera is the one the user is seeing thru falls upon you to maintain. Whereas when you use setCamera() to switch the active camera, that housekeeping is done for you, you can always retrieve the current active camera from the scene’s active_camera property.

That said, having multiple enabled cameras is a cool feature of Blender useful to know! The TutorialsForBlender3d site I referenced before also has an approachable, well-written tutorialon how to use multiple enabled cameras to create a split screen effect.