Index · Object → Engine

Engine

Provides access to engine properties.

Class Description

The Engine singleton allows you to query and modify the project's run-time parameters, such as frames per second, time scale, and others. It also stores information about the current build of Godot, such as the current version.

Properties

var max_fps: int = 0

The maximum number of frames that can be rendered every second (FPS). A value of 0 means the framerate is uncapped.

Limiting the FPS can be useful to reduce the host machine's power consumption, which reduces heat, noise emissions, and improves battery life.

If ProjectSettings.display/window/vsync/vsync_mode is Enabled or Adaptive, the setting takes precedence and the max FPS number cannot exceed the monitor's refresh rate. See also DisplayServer.screen_get_refresh_rate().

If ProjectSettings.display/window/vsync/vsync_mode is Enabled, on monitors with variable refresh rate enabled (G-Sync/FreeSync), using an FPS limit a few frames lower than the monitor's refresh rate will reduce input lag while avoiding tearing. At higher refresh rates, the difference between the FPS limit and the monitor refresh rate should be increased to ensure frames to account for timing inaccuracies. The optimal formula for the FPS limit value in this scenario is r - (r * r) / 3600.0, where r is the monitor's refresh rate.

Note: The actual number of frames per second may still be below this value if the CPU or GPU cannot keep up with the project's logic and rendering.

Note: If ProjectSettings.display/window/vsync/vsync_mode is Disabled, limiting the FPS to a high value that can be consistently reached on the system can reduce input lag compared to an uncapped framerate. Since this works by ensuring the GPU load is lower than 100%, this latency reduction is only effective in GPU-bottlenecked scenarios, not CPU-bottlenecked scenarios.

var max_physics_steps_per_frame: int = 8

The maximum number of physics steps that can be simulated each rendered frame.

Note: The default value is tuned to prevent expensive physics simulations from triggering even more expensive simulations indefinitely. However, the game will appear to slow down if the rendering FPS is less than 1 / max_physics_steps_per_frame of physics_ticks_per_second. This occurs even if delta is consistently used in physics calculations. To avoid this, increase max_physics_steps_per_frame if you have increased physics_ticks_per_second significantly above its default value.

var physics_jitter_fix: float = 0.5

How much physics ticks are synchronized with real time. If 0 or less, the ticks are fully synchronized. Higher values cause the in-game clock to deviate more from the real clock, but they smooth out framerate jitters.

Note: The default value of 0.5 should be good enough for most cases; values above 2 could cause the game to react to dropped frames with a noticeable delay and are not recommended.

Note: When using a custom physics interpolation solution, or within a network game, it's recommended to disable the physics jitter fix by setting this property to 0.

var physics_ticks_per_second: int = 60

The number of fixed iterations per second. This controls how often physics simulation and the Node._physics_process() method are run.

CPU usage scales approximately with the physics tick rate. However, at very low tick rates (usually below 30), physics behavior can break down. Input can also become less responsive at low tick rates as there can be a gap between input being registered, and the response on the next physics tick. High tick rates give more accurate physics simulation, particularly for fast moving objects. For example, racing games may benefit from increasing the tick rate above the default 60.

See also max_fps and ProjectSettings.physics/common/physics_ticks_per_second.

Note: Only max_physics_steps_per_frame physics ticks may be simulated per rendered frame at most. If more physics ticks have to be simulated per rendered frame to keep up with rendering, the project will appear to slow down (even if delta is used consistently in physics calculations). Therefore, it is recommended to also increase max_physics_steps_per_frame if increasing physics_ticks_per_second significantly above its default value.

Note: Consider enabling physics interpolation if you change physics_ticks_per_second to a value that is not a multiple of 60. Using physics interpolation will avoid jittering when the monitor refresh rate and physics update rate don't exactly match.

var print_error_messages: bool = true

If false, stops printing error and warning messages to the console and editor Output log. This can be used to hide error and warning messages during unit test suite runs. This property is equivalent to the ProjectSettings.application/run/disable_stderr project setting.

Note: This property does not impact the editor's Errors tab when running a project from the editor.

Warning: If set to false anywhere in the project, important error messages may be hidden even if they are emitted from other scripts. In a @tool script, this will also impact the editor itself. Do not report bugs before ensuring error messages are enabled (as they are by default).

var print_to_stdout: bool = true

If false, stops printing messages (for example using print()) to the console, log files, and editor Output log. This property is equivalent to the ProjectSettings.application/run/disable_stdout project setting.

Note: This does not stop printing errors or warnings produced by scripts to the console or log files, for more details see print_error_messages.

var time_scale: float = 1.0

The speed multiplier at which the in-game clock updates, compared to real time. For example, if set to 2.0 the game runs twice as fast, and if set to 0.5 the game runs half as fast.

This value affects Timer, SceneTreeTimer, and all other simulations that make use of delta time (such as Node._process() and Node._physics_process()).

Note: It's recommended to keep this property above 0.0, as the game may behave unexpectedly otherwise.

Note: This does not affect audio playback speed. Use AudioServer.playback_speed_scale to adjust audio playback speed independently of time_scale.

Note: This does not automatically adjust physics_ticks_per_second. With values above 1.0 physics simulation may become less precise, as each physics tick will stretch over a larger period of engine time. If you're modifying time_scale to speed up simulation by a large factor, consider also increasing physics_ticks_per_second to make the simulation more reliable.

Methods

func capture_script_backtraces(include_variables: bool = false) -> ScriptBacktrace[]

Captures and returns backtraces from all registered script languages.

By default, the returned ScriptBacktrace will only contain stack frames in editor builds and debug builds. To enable them for release builds as well, you need to enable ProjectSettings.debug/settings/gdscript/always_track_call_stacks.

If include_variables is true, the backtrace will also include the names and values of any global variables (e.g. autoload singletons) at the point of the capture, as well as local variables and class member variables at each stack frame. This will however will only be respected when running the game with a debugger attached, like when running the game from the editor. To enable it for export builds as well, you need to enable ProjectSettings.debug/settings/gdscript/always_track_local_variables.

Warning: When include_variables is true, any captured variables can potentially (e.g. with GDScript backtraces) be their actual values, including any object references. This means that storing such a ScriptBacktrace will prevent those objects from being deallocated, so it's generally recommended not to do so.

func get_architecture_name() -> String

Returns the name of the CPU architecture the Godot binary was built for. Possible return values include "x86_64", "x86_32", "arm64", "arm32", "rv64", "ppc64", "loongarch64", "wasm64", and "wasm32".

To detect whether the current build is 64-bit, or the type of architecture, don't use the architecture name. Instead, use OS.has_feature() to check for the "64" feature tag, or tags such as "x86" or "arm". See the Feature Tags documentation for more details.

Note: This method does not return the name of the system's CPU architecture (like OS.get_processor_name()). For example, when running an x86_32 Godot binary on an x86_64 system, the returned value will still be "x86_32".

func get_author_info() -> Dictionary

Returns the engine author information as a Dictionary, where each entry is an Array of strings with the names of notable contributors to the Godot Engine: lead_developers, founders, project_managers, and developers.

func get_donor_info() -> Dictionary

Returns a Dictionary of categorized donor names. Each entry is an Array of strings:

{platinum_sponsors, gold_sponsors, silver_sponsors, bronze_sponsors, mini_sponsors, gold_donors, silver_donors, bronze_donors}

func get_frames_drawn() -> int

Returns the total number of frames drawn since the engine started.

Note: On headless platforms, or if rendering is disabled with --disable-render-loop via command line, this method always returns 0. See also get_process_frames().

func get_frames_per_second() -> float

Returns the average frames rendered every second (FPS), also known as the framerate.

func get_license_info() -> Dictionary

Returns a Dictionary of licenses used by Godot and included third party components. Each entry is a license name (such as "Expat") and its associated text.

func get_license_text() -> String

Returns the full Godot license text.

func get_main_loop() -> MainLoop

Returns the instance of the MainLoop. This is usually the main SceneTree and is the same as Node.get_tree().

Note: The type instantiated as the main loop can changed with ProjectSettings.application/run/main_loop_type.

func get_physics_frames() -> int

Returns the total number of frames passed since the engine started. This number is increased every physics frame. See also get_process_frames().

This method can be used to run expensive logic less often without relying on a Timer:

func _physics_process(_delta):
	if Engine.get_physics_frames() % 2 == 0:
		pass # Run expensive logic only once every 2 physics frames here.
func get_physics_interpolation_fraction() -> float

Returns the fraction through the current physics tick we are at the time of rendering the frame. This can be used to implement fixed timestep interpolation.

func get_process_frames() -> int

Returns the total number of frames passed since the engine started. This number is increased every process frame, regardless of whether the render loop is enabled. See also get_frames_drawn() and get_physics_frames().

This method can be used to run expensive logic less often without relying on a Timer:

func _process(_delta):
	if Engine.get_process_frames() % 5 == 0:
		pass # Run expensive logic only once every 5 process (render) frames here.
func get_script_language(index: int) -> ScriptLanguage

Returns an instance of a ScriptLanguage with the given index.

func get_script_language_count() -> int

Returns the number of available script languages. Use with get_script_language().

func get_singleton(name: StringName) -> Object

Returns the global singleton with the given name, or null if it does not exist. Often used for plugins. See also has_singleton() and get_singleton_list().

Note: Global singletons are not the same as autoloaded nodes, which are configurable in the project settings.

func get_singleton_list() -> PackedStringArray

Returns a list of names of all available global singletons. See also get_singleton().

func get_version_info() -> Dictionary

Returns the current engine version information as a Dictionary containing the following entries:

- major - Major version number as an int;

- minor - Minor version number as an int;

- patch - Patch version number as an int;

- hex - Full version encoded as a hexadecimal int with one byte (2 hex digits) per number (see example below);

- status - Status (such as "beta", "rc1", "rc2", "stable", etc.) as a String;

- build - Build name (e.g. "custom_build") as a String;

- hash - Full Git commit hash as a String;

- timestamp - Holds the Git commit date UNIX timestamp in seconds as an int, or 0 if unavailable;

- string - major, minor, patch, status, and build in a single String.

The hex value is encoded as follows, from left to right: one byte for the major, one byte for the minor, one byte for the patch version. For example, "3.1.12" would be 0x03010C.

Note: The hex value is still an int internally, and printing it will give you its decimal representation, which is not particularly meaningful. Use hexadecimal literals for quick version comparisons from code:

if Engine.get_version_info().hex >= 0x040100:
	pass # Do things specific to version 4.1 or later.
else:
	pass # Do things specific to versions before 4.1.
func get_write_movie_path() -> String

Returns the path to the MovieWriter's output file, or an empty string if the engine wasn't started in Movie Maker mode. The default path can be changed in ProjectSettings.editor/movie_writer/movie_file.

func has_singleton(name: StringName) -> bool

Returns true if a singleton with the given name exists in the global scope. See also get_singleton().

print(Engine.has_singleton("OS"))          # Prints true
print(Engine.has_singleton("Engine"))      # Prints true
print(Engine.has_singleton("AudioServer")) # Prints true
print(Engine.has_singleton("Unknown"))     # Prints false

Note: Global singletons are not the same as autoloaded nodes, which are configurable in the project settings.

func is_editor_hint() -> bool

Returns true if the script is currently running inside the editor, otherwise returns false. This is useful for @tool scripts to conditionally draw editor helpers, or prevent accidentally running "game" code that would affect the scene state while in the editor:

if Engine.is_editor_hint():
	draw_gizmos()
else:
	simulate_physics()

See Running code in the editor in the documentation for more information.

Note: To detect whether the script is running on an editor build (such as when pressing F5), use OS.has_feature() with the "editor" argument instead. OS.has_feature("editor") evaluate to true both when the script is running in the editor and when running the project from the editor, but returns false when run from an exported project.

func is_embedded_in_editor() -> bool

Returns true if the engine is running embedded in the editor. This is useful to prevent attempting to update window mode or window flags that are not supported when running the project embedded in the editor.

func is_in_physics_frame() -> bool

Returns true if the engine is inside the fixed physics process step of the main loop.

func _enter_tree():
	# Depending on when the node is added to the tree,
	# prints either "true" or "false".
	print(Engine.is_in_physics_frame())

func _process(delta):
	print(Engine.is_in_physics_frame()) # Prints false

func _physics_process(delta):
	print(Engine.is_in_physics_frame()) # Prints true
func register_script_language(language: ScriptLanguage) -> Error

Registers a ScriptLanguage instance to be available with ScriptServer.

Returns:

- OK on success;

- ERR_UNAVAILABLE if ScriptServer has reached the limit and cannot register any new language;

- ERR_ALREADY_EXISTS if ScriptServer already contains a language with similar extension/name/type.

func register_singleton(name: StringName, instance: Object) -> void

Registers the given Object instance as a singleton, available globally under name. Useful for plugins.

func unregister_script_language(language: ScriptLanguage) -> Error

Unregisters the ScriptLanguage instance from ScriptServer.

Returns:

- OK on success;

- ERR_DOES_NOT_EXIST if the language is not registered in ScriptServer.

func unregister_singleton(name: StringName) -> void

Removes the singleton registered under name. The singleton object is not freed. Only works with user-defined singletons registered with register_singleton().

Inherited from Object (62)
func _get(property: StringName) -> Variant
func _get_property_list() -> Dictionary[]
func _init() -> void
func _iter_get(iter: Variant) -> Variant
func _iter_init(iter: Array) -> bool
func _iter_next(iter: Array) -> bool
func _notification(what: int) -> void
func _set(property: StringName, value: Variant) -> bool
func _to_string() -> String
func _validate_property(property: Dictionary) -> void
func add_user_signal(signal: String, arguments: Array = []) -> void
func call(method: StringName) -> Variant
func callv(method: StringName, arg_array: Array) -> Variant
func cancel_free() -> void
func connect(signal: StringName, callable: Callable, flags: int = 0) -> Error
func disconnect(signal: StringName, callable: Callable) -> void
func emit_signal(signal: StringName) -> Error
func free() -> void
func get(property: StringName) -> Variant
func get_class() -> String
func get_incoming_connections() -> Dictionary[]
func get_indexed(property_path: NodePath) -> Variant
func get_meta(name: StringName, default: Variant = null) -> Variant
func get_meta_list() -> StringName[]
func get_method_list() -> Dictionary[]
func get_property_list() -> Dictionary[]
func get_signal_connection_list(signal: StringName) -> Dictionary[]
func get_signal_list() -> Dictionary[]
func has_meta(name: StringName) -> bool
func has_method(method: StringName) -> bool
func has_signal(signal: StringName) -> bool
func is_class(class: StringName) -> bool
func is_connected(signal: StringName, callable: Callable) -> bool
func notification(what: int, reversed: bool = false) -> void
func remove_meta(name: StringName) -> void
func remove_user_signal(signal: StringName) -> void
func set(property: StringName, value: Variant) -> void
func set_block_signals(enable: bool) -> void
func set_deferred(property: StringName, value: Variant) -> void
func set_indexed(property_path: NodePath, value: Variant) -> void
func set_message_translation(enable: bool) -> void
func set_meta(name: StringName, value: Variant) -> void
func set_script(script: Variant) -> void
func set_translation_domain(domain: StringName) -> void
func to_string() -> String
func tr(message: StringName, context: StringName = &"") -> String
func tr_n(message: StringName, plural_message: StringName, n: int, context: StringName = &"") -> String

Signals

Inherited from Object (2)