- Home /
I'm having some trouble understanding how to switch cameras
It seems the common practice is to switch cameras by enabling and disabling them, however I keep running into problems no matter how I set this up. So I want to clear up a few things:
Tags. Do all cameras I want to switch between have to be tagged "MainCamera"?
Depth. Why does switching depth not work? Is depth only relevant when a scene is loaded?
Main camera vs current. Right now when I'm experiencing an issue where the Camera.main is one of the lower depth ones, and not the camera that is actually being viewed in game. Current camera points to the correct view, but I am told not to use current and to instead use main. Why is main inaccurate?
Answer by gregzo · Jul 29, 2013 at 05:50 AM
No.
Depth should work as expected, and controls which camera is rendered on top.
Camera.main returns the first enabled camera tagged MainCamera ( docs ). It will not be updated as you enable / disable other cams. You shouldn't use Camera.current neither ( check the docs again ). What you should do is to keep track of your various cams in a CamManager script, which can enable and disable them at will (it should hold references to all of them ).
Your answer
