+1 vote

Hi there. I am making a 2D game, but I have had some issues with the z-index, sometimes it draws the sprites in an order that is the one that I am not expecting. This made me think that maybe it has something to do with the property "Z Index as relative" that is toggled on by default. Can someone explain me when should I toggle this property and when not to?

in Engine by (97 points)

1 Answer

+1 vote

As documented...

If true, the node's Z index is relative to its parent's Z index. If this node's Z index is 2 and its parent's effective Z index is 3, then this node's effective Z index will be 2 + 3 = 5.

So, really, when checked, it lets you easily organize the z-index of a hierarchy of nodes relative to their parent. Then, you can easily adjust the entire hierarchy relative to other objects in the world simply by changing the z-index of the parent node(s) (and all the "relative" children will adjust automatically).

Really, it's just a convenience mechanism. You'll need to decide if it's helpful or not to use it in a given situation.

by (12,282 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.