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

2D Top Down Background Setup

Discussion in '2D' started by kenaochreous, Feb 25, 2015.

  1. kenaochreous

    kenaochreous

    Joined:
    Sep 7, 2012
    Posts:
    395
    I would like to setup a top down 2D background but I'm not sure how. I want to make sure that the background is always in the camera's view. I was looking at the camera's settings and you can adjust the color for the entire scene but I couldn't find anything that uses an image. Do you maybe place the background in the scene and parent it to the camera? But then how would you have it resize to fit the camera? Any clarification would be appreciated.
     
  2. imaginaryhuman

    imaginaryhuman

    Joined:
    Mar 21, 2010
    Posts:
    5,834
    you can add it as a plane or quad, like a floor, with at texture on it, then just put it in front of the camera as a CHILD of the camera.
     
    Nembuz likes this.
  3. kenaochreous

    kenaochreous

    Joined:
    Sep 7, 2012
    Posts:
    395
    Is there a way you can have the plane or quad automatically scale with the camera's Size? Like while you're making adjustments to the camera in the Unity Editor and not while playing?
     
  4. imaginaryhuman

    imaginaryhuman

    Joined:
    Mar 21, 2010
    Posts:
    5,834
    if you make it a child of the camera and it is always the same distance from the camera, covering the camera, if you change the resolution etc i presume it will still cover the whole thing and scale to fit?
     
  5. Wrymnn

    Wrymnn

    Joined:
    Sep 24, 2014
    Posts:
    352
    Sadly to say, you cannot "attach" background to camera in Unity. I have 2D top down game as well.

    This may sound messy but I created second camera, that is pointing on my background sprite. The second camera renders only this sprite, and my main camera renders everything but the background.

    Then, so your scene is not messy, you can place your second camera and background sprite into separate layer, let`s say called "background", and in upper right corner you can set, that objects with this layer will not be visible on your scene, so it wont happen that you accidentally move the sprite or something else.

    Then if you need to move the background or scale it, you just attach script into either your second camera or into your background sprite, and move/scale it accordingly.