Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Setup code for a 2d game on main camera or gameobject?

Discussion in 'Scripting' started by BusyRobot, Feb 10, 2015.

  1. BusyRobot

    BusyRobot

    Joined:
    Feb 22, 2013
    Posts:
    148
    I can't seem to find any guidance one way or the other on this, but is it better to set up your setup code for your 2d game on the main camera or a separate game object? Are there reasons to one over the other?
     
  2. SubZeroGaming

    SubZeroGaming

    Joined:
    Mar 4, 2013
    Posts:
    1,008
    What do you mean by set up code? There is no difference in using the main camera or an empty gameObject.
     
  3. BusyRobot

    BusyRobot

    Joined:
    Feb 22, 2013
    Posts:
    148
    If you're using a singleton approach I guess, and you put your main game start code on one object, would that be better to be the main camera or a seperate gameObject. I've seen examples of both and I wondered why use one over the other.
     
  4. SubZeroGaming

    SubZeroGaming

    Joined:
    Mar 4, 2013
    Posts:
    1,008
    When setting up a game manager, I'll typically use an empty Object. In the old Unity, before 4.6, I would use the main camera strictly for my GUI Manager. It's really a personal preference. Now the only thing that ever goes on the main camera are scripts to manipulate it.
     
    BusyRobot likes this.
  5. The-Little-Guy

    The-Little-Guy

    Joined:
    Aug 1, 2012
    Posts:
    297
    I usually put my game controller on the camera, but for the game controller you want to put it on something that doesn't EVER get destroyed during the scene.

    For everything else, you place it on the object that you want it it relate to.