How do I centre my screen, instead of the debug mode starting at the bottom right(some of it hidden)?

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

I am quite confused with the answer above as I do not understand how the code works:
Where do i type the following code into?
Which Node should I create the script into?
What exactly should I do if this piece of code doesn’t work?
I really appreciate your answers and I am hoping for you to find a solution to this as quick as possible!

P.S. Thank you to whoever spends their precious time trying to find a solution for us, It really helps! (When I mean ‘us’, I mean every person who you have spent your time on)

Here is the answer that I saw:

var screen_size = OS.get_screen_size(screen=0)
var window_size = OS.get_window_size()
OS.set_window_position(screen_size*0.5 - window_size*0.5)

godotisgreat | 2022-10-02 17:14

Call this code in the _onready() of your first node.

SteveSmith | 2022-10-02 17:59

Placing it into an autoload would be good place, this way it’s not dependent of which scene was run. Just created a script for Node, and add the code to func _ready():. Add this script to Project Settings / AutoLoad.

But check also the other method I mentioned in my actual answer.

aXu_AP | 2022-10-04 17:56

Thank you for your responses!

godotisgreat | 2022-10-13 16:41

:bust_in_silhouette: Reply From: aXu_AP

While the answer you linked is good for exported projects, for debugging there’s actually editor setting for it. Open Editor / Editor Settings / Run / Window Placement to select from multiple choices, including custom coordinates and selecting monitor. It should be centered by default, but I remember having some problem with it too, custom worked (now it seems to be working fine with center).

Thank you so much for your response!

godotisgreat | 2022-10-13 16:41

THANK YOU SO MUCH

purplfish | 2023-06-15 05:07