One scene is centered, the other isn't

Godot Version

Godot v4.4.1

Question

TLDR: I have two scenes in a 2d game that seem exactly the same, but one is correctly centered on the screen and one isn’t. What could be going on?

Details:
I want my game screen to be always centered in the game window even when the window’s aspect ratio changes. My current project settings are:

  • Mode: Windowed
  • Initial position type: Center of primary screen
  • Initial position: 0,0
  • Stretch mode: canvas_items
  • Aspect: Expand

I have two screens: my title screen and game screen. My game screen is positioned correctly and stays in the center of the window when the aspect ratio is changed. However my title screen is always positioned 0,0 on the top left, and stays there when the game window is resized

I don’t think this is an issue with anchors, as both scenes are regular 2d nodes, not control nodes.

Thing’s I’ve tried:

  • Printing the positions of 2 scenes (both global and local position of both are 0,0)
  • Seeing if any settings in the scene node are different (they are not)

Does anyone have any experience with this issue or knows what could be causing it?
TYSM!

You might want to look into what world positions are and how these are processed into screen coordinates more. Initial position type: Center of primary screen has no effect on the positioning of things inside the game. Neither positions of the root nodes gonna tell you what is where on the screen; these will just sit where you have placed them in the editor.

My guess is, your game screen uses a camera and the camera just displays the things around it, while title screen does not and is projected to the screen as is.

1 Like

I would like to reproduce the problem, I have the feeling that there is a simple solution, can you please attach a minimal example? Thank you.

Hi! Didn’t see this reply until now but this turned out to be correct- the title screen didn’t have a camera. Thank you!