I know that
CanvasLayers have a
level attribute which determines the order they are drawn.
Further, I know that Godot renders things according to their order in the scene hierarchy, with lower nodes being drawn on top of higher nodes.
But I am wondering if there is a way to specify the draw level on an object-by-object basis?
For example, suppose I have two sprites at different positions in my scene hierarchy and I want to draw the one higher in the hierarchy on top of the lower one. Is there a way to do this? For instance, can I use code to specify the draw level of the sprite higher in the tree such that it is drawn above the sprite lower in the tree?
The reason I ask is because I have a complex tree structure in which I use nodes as containers for my game objects. For example, I have a node called Enemies into which enemy nodes are placed during the generation of levels. I also have a node for Effects, Hazards, etc. and depending on the effect or hazard, I may want it to be drawn on a different level from other effects or hazards.