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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Layers Help

Discussion in '2D' started by JohnnyMc, Jul 16, 2015.

  1. JohnnyMc

    JohnnyMc

    Joined:
    Apr 28, 2015
    Posts:
    61
    I am working through the book "Learning 2D Game Development with Unity" and continue to find issues I am struggling with. The book tells me to create 4 layers under "SORTING LAYERS" and then I can use that to assign a layer to my game objects. I have done this but "sorting" layers dont show up in the inspector for game objects, only layers do so I can not assign these sorting layers to my game objects. I am trying to place a fence in the foreground so my player will walk behind it

    Can someone explain what the difference between "sorting" layers and "layers" is?

    Should I just create my layers under layers and forget what the book says on this so I can assign them to objects?

    How do I assign a sorting layer to a game object?
     
  2. LaneFox

    LaneFox

    Joined:
    Jun 29, 2011
    Posts:
    7,384
    Layers:
    Background organizational identifier for an object, like "Enemies" layer, or "Props" layer.

    Sorting Layers:
    What order things are rendered.
     
    theANMATOR2b likes this.
  3. JohnnyMc

    JohnnyMc

    Joined:
    Apr 28, 2015
    Posts:
    61
    So a "layer" is just an identifier to keep things grouped while the "sorting layer" is used to place objects in front of and behind the player?
     
  4. LaneFox

    LaneFox

    Joined:
    Jun 29, 2011
    Posts:
    7,384
    Basically, yeah.
     
  5. itzclay36

    itzclay36

    Joined:
    Apr 11, 2015
    Posts:
    25
    I use a "layer" to decide what is going to collide with each other within the 2d physics settings and things of that nature rather than as an identifier. I use tags for identifying purposes.
     
    theANMATOR2b likes this.
  6. blizzy

    blizzy

    Joined:
    Apr 27, 2014
    Posts:
    775
    "Layers" can also be used by the camera to decide what's visible to that camera and what is not.