I don't know if what I've done is the correct method or not. I discovered that you can get layers by the order that you create objects. I mean, the first one is on top, second one is beneath it and so on. That seems pretty primitive because, then, how can you add an object at layer 2 later? I am sure I'm missing something here. Thanks in advance!
Comments
In the camera you set the GroupĹist, which will determine the order of the rendering (keep in mind that the last ones will be on top of the scene, since they are rendered over the first ones)
And on the object you set Group property:
so: (200, 200, -0.1) will be on top of (200, 200 0.0). That is the easiest way to sort out who is on top. Then, as Knolan says, you can use the GroupList for layering in addition.
Note that groups do no intersect between each other, they are rendered separately. Within each group, the sorting is done based on the Z coordinate (and then batching occurs based on texture, filtering and shader, but that will never break the ordering).
Groups are more intended to separate objects for easy compositing/post-processing as well as for handling hidden objects and debug rendering of those.
For example, in most of my games I have a few groups that will render to a texture via a camera/viewport couple, then some compositing or post-processing will happen, then rendering of higher layers (UI/fade outs) will be done on top of that result and won't be affected by the aforementioned post-processing.