Instanced scene is not positioned correctly

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By psear

I have a “main” scene and a “menu” scene. When I edit the menu scene on its own, it is positioned correctly in the display, centered (it’s a control scene with everything inside a CentreContainer). But when I instance it via code from my main scene, the whole menu moves to the top left. What am I doing wrong?

Are you using a camera node to follow the player? And, if so, is your menu instanced as the child of a canvas layer?

DigitalDrako | 2020-06-13 20:19

:bust_in_silhouette: Reply From: deaton64

Hi,
Is the menu a child of the main scene? if so, it will take it’s position from that scene.

Try this: get_parent().add_child(the_menu_scene)

Thanks, yes, I had checked that it was a child of the scene, but I found the problem turned out to be the rect_size.

psear | 2020-06-14 13:08

:bust_in_silhouette: Reply From: psear

Just putting this here as I found an answer, as it turned out, the rect_size didn’t follow through when I instanced it, it just started as the minimum rect_size, so I set the minimum rect size on the initial scene to the value I needed it to be, and all is good.