order objects in scene

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By popon2
:warning: Old Version Published before Godot 3 was released.

Hi guys,
How to change order (or succession - google translator - I dont no how to say it) of object in scene - if I want to have text in the foreground and other objects in backround.

:bust_in_silhouette: Reply From: umfk

The answer to this depends on exactly what you are doing.

Generally the nodes are drawn in order, that means the first child is drawn first, then the second one etc.

For isometric games there is also the Y ordering where children of the tilemap are drawn depending on their Y-value on the screen. Objects that are closer to the bottom of the screen are considered in front of objects further up.

Then there is a Z-value for all objects that inherit Node2D that you can use to move some objects to another layer so to speak.

Depending on what exactly you want to achieve you should choose one of these three methods.

Edit: dc1a0 reminded me of CanvasLayers. They have a property that is just called “layer” which kind of works like a Z-value. But additionally they can be made independent of the camera (good for a HUD) or to move faster than other layers (ParallaxBackground). More infor here.

With the specifics of their question, I’d also add that there’s CanvasLayer that puts all its children in the front, and ParallaxBackground that puts all its children in the back.

dc1a0 | 2016-03-14 18:52

With CanvasLayers I always think of camera independent movement and OPs questions (to me) didn’t sound like he wants to do a HUD, but I might be wrong. I added the info to my answer anyways, thanks! :slight_smile:

umfk | 2016-03-14 19:06

I want to say - in 2d from top down view - can i do it from inspector?

popon2 | 2016-03-14 19:31

You have to give some more information on what you want to achieve. Do you want to do a HUD? Then use CanvasLayer. Do you want to do name tags/health bars? Use the Node2D Z-value. You can do all of these things from the editor without any coding.

umfk | 2016-03-14 19:36