Layout centering the pause menu

Godot Version

4.4.stable

Question

Could you please advise on layout and containers, as I’m trying to center the pause menu, but it always appears at Vector2(0,0). The pause menu is preloaded and shown on pause button pressed signal.
Current tree:

  • Control
  • CenterContainer
    
  • TextureRect
    
  •        CenterContainer
    
  •             VboxContainer
    
  •                   MenuButton ( start )
    
  •                   MenuButton ( exit )
    

Thank you in advance. I tried anchoring but the menu always appears at 0,0

Is your control node a child of a canvas layer? If it is, and your Control node container sizing is set to full screen, then your pause container, a child of the Control node, would be set to a container sizing “shrink centre”. Then everything that is a child of that container (like your pause button) would be centred on your screen.

No, the pause menu has only a root node “Control”, the scene is pre-uploaded in the pause button root node, and instantiated when the button is pressed.
Just to note, the pause button and pause menu are different scenes

So what is the root of the pause button. I think a control node by itself will either take the viewport as its root (hence the position 0,0 you get) or the parent if the parent inherits from canvas layer. I am not sure about the latter.

If it is not in a canvas layer then camera movements will affect the positioning too which is not much use for UI elements. If you make your pause menu root a canvas layer, it will then always be anchored you the view. So you could solve this by making your pause menu root a canvas layer with the control as a child of it.

Run your game and pause the game when you are experiencing the issue. Then on the scene list tab click ‘remote’ to see that actual tree that is running like this:

If you share the tree structure perhaps we can help see if your problem is there.

Anyway, hope you get it fixed soon.