0 votes

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)

Godot version v3.5.1
related to an answer for: How to center game window?
in Engine by (26 points)

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)

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

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.

Thank you for your responses!

1 Answer

+1 vote

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).

by (1,100 points)

Thank you so much for your response!

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.