2
\$\begingroup\$

I created a new camera in Unity's 2D mode, and for some reason it's being set as the main camera, despite not being tagged as such. The original main camera is in fact tagged as "main camera" but it will only display if the other one is disabled. Why do the cameras behave this way?

Here's the MainCamera, which is no longer the default:

Main camera

Here's the BattleCamera, which for some reason is the default:

Battle camera

\$\endgroup\$
2
  • \$\begingroup\$ Does your game need to have 2 cameras up and running at the same time ? Can you disable one if you don't need both to be active at the same time, and only enable one camera to be active when it needs to be ? \$\endgroup\$ Mar 5 at 7:55
  • \$\begingroup\$ What do you mean with "tagged as main camera"? If you are referring to the "Tag"-field on top of the inspector: That doesn't really do anything except make it possible to find the object via the FindObjectWithTag method. It doesn't give the camera any special role. \$\endgroup\$
    – Philipp
    Mar 5 at 9:42

1 Answer 1

6
\$\begingroup\$

Unity uses the depth property to determine the order that cameras are drawn in. If two cameras have the same depth, there's no guarantee which camera will be drawn first.

Unity will render any camera that is currently active and enabled, even if only one of those camera views is currently visible to the player. To avoid performance issues, it is very important to deactivate any camera that isn't currently being used (with camera.enabled = false or camera.gameObject.SetActive(false)). Properly managing your cameras will also prevent confusion about which camera should currently be visible to the player.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .