- Home /
Which is the difference between layer and sorting layer?
If I'm not wrong, on 2D games, the sorting layer have preference over the z position for showing layers. After the sorting layer, the order in layer is the next more important value, and only after this one, the z position. Am I right?
Also, what's the layers (not sorting layers) for?
Regular 'Layers' are used for setting up physics collision rules and camera culling. You can view the Layer Collision $$anonymous$$atrix by going to Edit/Project/Physics. You can remove Layers from Camera Culling $$anonymous$$ask(s) by selecting a camera in the Hierarchy or Scene View, and finding the Culling $$anonymous$$ask drop-down in the Inspector.
Answer by Tekksin · Jun 13, 2014 at 09:57 PM
if I'm not mistaken, the sorting layer is used for 2D games. You have the name of the sorting layer, and then the number below it. So say you have 2 enemies (bing and bong), and you want bing to be in front of bong. Well, then you would tag them with an "enemies" sorting layer, made by you (doesn't have to be named enemies, it's your choice), and you would put bing on sorting layer number 2, and bong on sorting layer number 1.
Other sorting layers can be made for things like the player and decorations. You would place those sorting layers in the appropriate orders.
The regular "Layer" tagging option up at the top is for collisions (for me). You would tag things with layers. Pretend you didn't want bing and bong to touch, because they're enemies. You would put them on the enemies layer, and ensure in edit>project>physics/physics2D that where the horizontal and vericle lines meet is unchecked for the enemy titles. The rest of the layers shows what the enemies will hit, unless unchecked in the respected column.
Answer by ClockworkCoyote · Dec 20, 2016 at 05:41 PM
Sorting Layers are how objects are seen by the camera. This becomes obvious when you remember that sorting layers are attached to the renderer. Therefore, sorting layers (and order in sorting layers) determine how objects are rendered in the scene.
Layer, up there next to tags, is for grouping objects. Maybe you have a bunch of objects that are similar in that they will be rendered differently from other objects. They would be on different layers. Or, if only certain objects are supposed to be collidable and some are not, they would be on different layers.
Sorting layers are visual.
Layers are functional.