Hello all, hope I'm posting in the right session. My Popup Menu is being draw behind of sprites and Containers(with Labels) with Z_index bigger than Zero.

From what I understood others Controls inherent certain 'features' from its parent. Like a VBoxContainer child of a Node2D will render at the z_index of its parent, and the Anchor (0, 0, 0, 0) is relative to the parent position. However this don't seem to be the case for Popups?

I'm creating a Card Game and on start the game instantiate a Card scene in the battlefield. This card node is set to z_index = 2, so it renders above everything else despite tree order. This Card scene has a popup menu that appears when you click on the card. The problem as far as I know is that the popup (Control Node) render in the z_index = 0 and goes behind the card itself (Kinematic body) that is in the z_index = 2. If I set the Card to z_index 0 the popup appears on top, but I can't render everything at index 0.

How to make a popup appears at top of everything else? Here some screenshots of what it looks like, and of the tree at runtime.

I think z index is global. And you can go to negative numbers if you want.

You can also set the Z-index of Control-based nodes using the VisualServer singleton. The canvas_item_set_z_index function is the one you'll want to use, and you'll need to use get_canvas_item to get the RID to use. However, one thing to keep in mind is that how Control-based nodes handle inputs is based on the structure of the node tree, so changing the Z-index may make it appear on top of nodes but other Control-based nodes may block input if they are overlaying in the scene node tree.

Thanks for the replies. When I first post a concern was if my topic was a classic XY Problem. In the end, it kinda of was but not entirely. I had the idea that the Z-index was the only way to render elements in front of others, despite the tree order. However while thinking about how games render GUI elements always in front, like the HUD in a FPS per example. I search the documentation and found out about Canvas Layers. For me this is a really clean and direct way to put the control node in 'front' of everything else, and not mind the Z-index of the popupmenu. Although the information about a negative Z-index, and @TwistedTwigleg explanation will surely be useful in my future endeavour with Godot.

TLDR: Approaching the Popmenu as a GUI element didn't seem to be wrong, and thus I got to read the documentation about it. For my needs the answer was using a Canvas Layer node to put the popup in front of everything else.

Thanks again for the attention and replies. I will make sure to post videos of the prototype here in the forum, and in the Reedit in the future.

a year later