Hello, people!

We have a question about the layers displaying in a 2d scene.

It is needed to arrange the layers so that the objects below are located on the layer above, and some objects are always higher than others.

We have problems with it, because when objects are spawned, then new ones overlap the old ones.

The question is how to work properly with layers in a 2D scene?

Thanks!

You can arrange your layers by change the Z index. In theory you just set all of the objects you want on the bottom layer to one Z index value (like 0), and layers above to a higher Z value (like 10. If you jump from 0 to 10 that gives you some flexibility later if you want to add layers in between).

As Megalomaniak said in this topic:

So the idea is that sprites get drawn in a certain order such that ones drawn in front/on top of others are drawn later. That order of 'depth' should be determined by an index number z(depth axis)-index.

http://docs.godotengine.org/en/3.0/tutorials/2d/canvas_layers.html#canvaslayers http://docs.godotengine.org/en/3.0/tutorials/2d/canvas_layers.html#performance http://docs.godotengine.org/en/3.0/classes/class_node2d.html#class-node2d-z-index

@TwistedTwigleg said: You can arrange your layers by change the Z index. In theory you just set all of the objects you want on the bottom layer to one Z index value (like 0), and layers above to a higher Z value (like 10. If you jump from 0 to 10 that gives you some flexibility later if you want to add layers in between).

As Megalomaniak said in this topic:

So the idea is that sprites get drawn in a certain order such that ones drawn in front/on top of others are drawn later. That order of 'depth' should be determined by an index number z(depth axis)-index.

http://docs.godotengine.org/en/3.0/tutorials/2d/canvas_layers.html#canvaslayers http://docs.godotengine.org/en/3.0/tutorials/2d/canvas_layers.html#performance http://docs.godotengine.org/en/3.0/classes/class_node2d.html#class-node2d-z-index

Thank you! We'll try it.

4 years later