x


Active camera on Start

I have two cameras in my scene; one in first person and the other in third person. I want the first person camera (tagged as MainCamera) to be the active camera when the game starts. Once the player hits a trigger, the second camera should then become active. I cannot seem to figure out how to disable the second camera when starting. How do I ensure that only the main camera is active when starting?

more ▼

asked Aug 25 '11 at 03:11 PM

Tim.Holman gravatar image

Tim.Holman
136 25 25 27

I'm having a similar problem where the MainCamera tag isn't working for assigning the first camera. My current workaround is to disable all the other cameras so that only one camera component is enabled at a time. Still, I'd like to know if there's a better way to do this.

Aug 25 '11 at 03:22 PM sharat

Both should probably stay tagged MainCamera. This tag is used for Camera.main, and it only finds active cameras.

Aug 25 '11 at 03:24 PM Waz
(comments are locked)
10|3000 characters needed characters left

1 answer: sort oldest

Simply set the GameObject inactive in the scene - the little checkbox top-left in the Inspector.

Then to swap cameras:

camera1.gameObject.active = false;
camera2.gameObject.active = true;

If you want to transition between the two cameras, you will be better with just one camera (which you move between two locations).

more ▼

answered Aug 25 '11 at 03:21 PM

Waz gravatar image

Waz
6.4k 22 33 70

If you´re instantiating prefabs you have to set the ones you don´t want to be active through code as well, because every prefab+it's children gets instantiated as active=true.

Aug 25 '11 at 03:52 PM Joshua

You can also set just the Camera component to be inactive. That should work for prefabs as well.

Aug 25 '11 at 05:38 PM sharat
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x2988
x981
x156
x112

asked: Aug 25 '11 at 03:11 PM

Seen: 1978 times

Last Updated: Aug 25 '11 at 05:38 PM