I want to have two different cameras in my game, one top down and one 3rd person, and I want them to be changeable when you press a key, or change an option in the GUI. Is it possible to select a different main camera or would I have to move the main camera?
asked Apr 27, 2010 at 04:16 PM
You can do either, although it's probably simpler to switch between cameras.
To change the main camera, you can set the "active" properties of the camera gameobjects, or you can set the "enabled" properties of the camera components on the gameobjects. It's often preferable to use the enabled property, which is shown below:
Camera.main refers to the first enabled camera tagged with "MainCamera", so you can tag both cameras with this tag, and use a simple script to toggle between them like this:
Place this script on a gameobject in your scene (for example, your player, or a new empty gameobject), and drag references to both your cameras into the "cam1" and "cam2" variables respectively.
The static variable "Camera.main" will always refer to the currently active camera out of these two.
answered Apr 27, 2010 at 04:25 PM
Here's how I did it with three cameras: