Skip to content

How to set the window size in Godot 4: get_window().size

By Eduardo Orellana · Updated

Set get_window().size = Vector2i(1280, 720) in code, or set the default in Project Settings, Display, Window, Size. Godot 3's OS.window_size is gone: it fails to parse with Cannot find member "window_size" in base "OS".

AppImage, x86_64. Ubuntu 22.04, Debian 12, Fedora 39 or newer.

Intel or AMD Chromebook, with Linux turned on.

Download for macOSDownload for WindowsDownload for Linux

What Godot is checking

Godot 4 moved window control off OS. Each window is a Window node, the game's main one is get_window() from any node, and its size, position and mode are its properties. DisplayServer offers the same calls by window id.

The size is a Vector2i, in pixels. This page's run is headless, with no real window, and shows the Window node taking the size.

Reproduce it

A Godot 3 window size, in a Godot 4 project.

More on this: PoolStringArray in Godot 4: it is PackedStringArray now

GDScript
extends Node

func _ready():
	OS.window_size = Vector2(1280, 720)

What Godot 4.7.2 prints

Output
Godot Engine v4.7.2.stable.mono.official.ed1daf0bf - https://godotengine.org

SCRIPT ERROR: Parse Error: Cannot find member "window_size" in base "OS".
   at: GDScript::reload (res://answers/how-to-set-the-window-size-in-godot-4/repro.gd:4)
ERROR: Failed to load script "res://answers/how-to-set-the-window-size-in-godot-4/repro.gd" with error "Parse error".
   at: load (modules/gdscript/gdscript_resource_format.cpp:46)

Fix it

Set the main window's size and read it back.

GDScript
extends Node

func _ready() -> void:
	get_window().size = Vector2i(1280, 720)
	print(get_window().size)

What the fixed script prints

Output
Godot Engine v4.7.2.stable.mono.official.ed1daf0bf - https://godotengine.org

(1280, 720)

Run this fix with your agent

Flockbay is the Godot editor with an AI agent built in. Paste this into Flockbay's chat, or into Claude Code or Codex connected to Flockbay over MCP: the agent finds the cause in your project, applies the fix, runs the game headless and reads Godot's output to check it.

More on this: How to disable and enable a node in Godot 4: process_mode

Prompt
How to set the window size in Godot 4: get_window().size Set get_window().size = Vector2i(1280, 720) in code, or set the default in Project Settings, Display, Window, Size. Godot 3's OS.window_size is gone: it fails to parse with Cannot find member "window_size" in base "OS". Where this calls for a change in my Godot 4 project, make it, then run the game headless and check Godot's output for errors.

Verified on Godot 4.7.2

Both scripts on this page were run headless on Godot 4.7.2 (4.7.2.stable.mono.official.ed1daf0bf) on 18 October 2026, and the output above is what Godot printed, unedited.

Where the check lives in Godot's source: gdscript_analyzer.cpp line 4122, the message, Window.size in the class reference.

Questions

How do I make the window fullscreen?
get_window().mode = Window.MODE_FULLSCREEN, or DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_FULLSCREEN).
How do I keep the game the same size on any window?
Set Project Settings, Display, Window, Stretch, Mode to canvas_items or viewport, and pick an aspect.

Flockbay's agent reads Godot's debugger output and fixes errors like this one in your project, on the official Godot.

Download Flockbay free