- Home /
How to set main camera?
How do I set the main camera without using gameObject.active = false or true;?
Answer by Jessy · May 08, 2011 at 09:09 AM
Camera.main is
The first enabled camera tagged "MainCamera" (Read Only)
Therefore, you just change the tag of the camera you want to be it, and the tag of the one that had previously been it.
when running my scene the view is taken from a camera which is not my main camera. it is just a camera attached to a cube. my main camera has the tag "main camera" and the other camera is untagged. any ideas of why is this happening?
Answer by SirMarley · Aug 14, 2014 at 10:06 PM
The best and easiest way to do it... just go into another scene you have, copy the main camera, go back to the scene where you have deleted it and paste it.
It is a very simple solution, but works very well. Thanks.
Answer by srmojuze · Jun 02, 2015 at 07:15 AM
I like using (your gameobject).camera.enabled = true; to activate and deactivate cameras. This way you can keep the game objects active and just enable and disable the camera component to "switch" between cameras. (Note that now the proper syntax is to get the camera component using GetComponent)
Your answer
Follow this Question
Related Questions
Main Camera Switch? 3 Answers
object collision attatched to camera 1 Answer
Swapping Cameras Disables Keyboard Input 3 Answers
Issues with switching cameras 1 Answer
setting a character controller orientation by script 1 Answer