Positioning issue due to maximized game viewport

Godot Version



I’m making a simple game. I set the viewport size to below:

  • Viewport Width: 1280
  • Viewport Height: 720

I also have this Panel node scene which I want to instantiate via code:

I’m doing it like so:

var credit_scene = credit_sub_scene.instantiate()

But the credit scene is not aligning to the center after clicking a button to add it to the root scene, even though I placed it to the center in the editor.

See visual:

Is there something I should do and a setting I should tweak for it to be centered at runtime? Thanks

spawn the credit panel inside a CenterContainer Node that has the layout using Anchors and set it to Full Rect. If suddenly your panel collapse to zero sizes, then you just need to add custom minimum size to it

1 Like

Thanks, i will try out your suggestion

Hi, did what you said, I placed the Panel node in the CenterContainer node, but now, when I click the Credits button, the panel doesn’t have a background. Like, there’s no visual on screen to see the panel

has full rect enabled?

can only mean two things, 1. your center container is so small, 2. your Panel for Credits doesnt have custom minimum size set