Engine

Inherits:Object

Provides access to engine properties.

Description

TheEngine 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

int

max_fps

0

int

max_physics_steps_per_frame

8

float

physics_jitter_fix

0.5

int

physics_ticks_per_second

60

bool

print_error_messages

true

bool

print_to_stdout

true

float

time_scale

1.0

Methods

Array[ScriptBacktrace]

capture_script_backtraces(include_variables:bool = false)const

String

get_architecture_name()const

Dictionary

get_author_info()const

Array[Dictionary]

get_copyright_info()const

Dictionary

get_donor_info()const

int

get_frames_drawn()

float

get_frames_per_second()const

Dictionary

get_license_info()const

String

get_license_text()const

MainLoop

get_main_loop()const

int

get_physics_frames()const

float

get_physics_interpolation_fraction()const

int

get_process_frames()const

ScriptLanguage

get_script_language(index:int)const

int

get_script_language_count()

Object

get_singleton(name:StringName)const

PackedStringArray

get_singleton_list()const

Dictionary

get_version_info()const

String

get_write_movie_path()const

bool

has_singleton(name:StringName)const

bool

is_editor_hint()const

bool

is_embedded_in_editor()const

bool

is_in_physics_frame()const

Error

register_script_language(language:ScriptLanguage)

void

register_singleton(name:StringName, instance:Object)

Error

unregister_script_language(language:ScriptLanguage)

void

unregister_singleton(name:StringName)


Property Descriptions

intmax_fps =0🔗

The maximum number of frames that can be rendered every second (FPS). A value of0 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.

IfProjectSettings.display/window/vsync/vsync_mode isEnabled orAdaptive, the setting takes precedence and the max FPS number cannot exceed the monitor's refresh rate.

IfProjectSettings.display/window/vsync/vsync_mode isEnabled, on monitors with variable refresh rate enabled (G-Sync/FreeSync), using an FPS limit a few frames lower than the monitor's refresh rate willreduce input lag while avoiding tearing.

See alsophysics_ticks_per_second andProjectSettings.application/run/max_fps.

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: IfProjectSettings.display/window/vsync/vsync_mode isDisabled, 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.


intmax_physics_steps_per_frame =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 than1/max_physics_steps_per_frame ofphysics_ticks_per_second. This occurs even ifdelta is consistently used in physics calculations. To avoid this, increasemax_physics_steps_per_frame if you have increasedphysics_ticks_per_second significantly above its default value.


floatphysics_jitter_fix =0.5🔗

How much physics ticks are synchronized with real time. If0 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 of0.5 should be good enough for most cases; values above2 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 to0.


intphysics_ticks_per_second =60🔗

The number of fixed iterations per second. This controls how often physics simulation andNode._physics_process() methods are run. This value should generally always be set to60 or above, as Godot doesn't interpolate the physics step. As a result, values lower than60 will look stuttery. This value can be increased to make input more reactive or work around collision tunneling issues, but keep in mind doing so will increase CPU usage. See alsomax_fps andProjectSettings.physics/common/physics_ticks_per_second.

Note: Onlymax_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 ifdelta is used consistently in physics calculations). Therefore, it is recommended to also increasemax_physics_steps_per_frame if increasingphysics_ticks_per_second significantly above its default value.


boolprint_error_messages =true🔗

Iffalse, 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 theProjectSettings.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 tofalse 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. Donot report bugs before ensuring error messages are enabled (as they are by default).


boolprint_to_stdout =true🔗

Iffalse, stops printing messages (for example using@GlobalScope.print()) to the console, log files, and editor Output log. This property is equivalent to theProjectSettings.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 seeprint_error_messages.


floattime_scale =1.0🔗

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

This value affectsTimer,SceneTreeTimer, and all other simulations that make use ofdelta time (such asNode._process() andNode._physics_process()).

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

Note: This does not affect audio playback speed. UseAudioServer.playback_speed_scale to adjust audio playback speed independently oftime_scale.

Note: This does not automatically adjustphysics_ticks_per_second. With values above1.0 physics simulation may become less precise, as each physics tick will stretch over a larger period of engine time. If you're modifyingtime_scale to speed up simulation by a large factor, consider also increasingphysics_ticks_per_second to make the simulation more reliable.


Method Descriptions

Array[ScriptBacktrace]capture_script_backtraces(include_variables:bool = false)const🔗

Captures and returns backtraces from all registered script languages.

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

Ifinclude_variables istrue, 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 enableProjectSettings.debug/settings/gdscript/always_track_local_variables.

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


Stringget_architecture_name()const🔗

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, useOS.has_feature() to check for the"64" feature tag, or tags such as"x86" or"arm". See theFeature Tags documentation for more details.

Note: This method doesnot return the name of the system's CPU architecture (likeOS.get_processor_name()). For example, when running anx86_32 Godot binary on anx86_64 system, the returned value will still be"x86_32".


Dictionaryget_author_info()const🔗

Returns the engine author information as aDictionary, where each entry is anArray of strings with the names of notable contributors to the Godot Engine:lead_developers,founders,project_managers, anddevelopers.


Array[Dictionary]get_copyright_info()const🔗

Returns anArray of dictionaries with copyright information for every component of Godot's source code.

EveryDictionary contains aname identifier, and aparts array of dictionaries. It describes the component in detail with the following entries:

  • files -Array of file paths from the source code affected by this component;

  • copyright -Array of owners of this component;

  • license - The license applied to this component (such as "Expat" or "CC-BY-4.0").


Dictionaryget_donor_info()const🔗

Returns aDictionary of categorized donor names. Each entry is anArray of strings:

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


intget_frames_drawn()🔗

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 returns0. See alsoget_process_frames().


floatget_frames_per_second()const🔗

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


Dictionaryget_license_info()const🔗

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


Stringget_license_text()const🔗

Returns the full Godot license text.


MainLoopget_main_loop()const🔗

Returns the instance of theMainLoop. This is usually the mainSceneTree and is the same asNode.get_tree().

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


intget_physics_frames()const🔗

Returns the total number of frames passed since the engine started. This number is increased everyphysics frame. See alsoget_process_frames().

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

func_physics_process(_delta):ifEngine.get_physics_frames()%2==0:pass# Run expensive logic only once every 2 physics frames here.

floatget_physics_interpolation_fraction()const🔗

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.


intget_process_frames()const🔗

Returns the total number of frames passed since the engine started. This number is increased everyprocess frame, regardless of whether the render loop is enabled. See alsoget_frames_drawn() andget_physics_frames().

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

func_process(_delta):ifEngine.get_process_frames()%5==0:pass# Run expensive logic only once every 5 process (render) frames here.

ScriptLanguageget_script_language(index:int)const🔗

Returns an instance of aScriptLanguage with the givenindex.


intget_script_language_count()🔗

Returns the number of available script languages. Use withget_script_language().


Objectget_singleton(name:StringName)const🔗

Returns the global singleton with the givenname, ornull if it does not exist. Often used for plugins. See alsohas_singleton() andget_singleton_list().

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


PackedStringArrayget_singleton_list()const🔗

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


Dictionaryget_version_info()const🔗

Returns the current engine version information as aDictionary 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, or0 if unavailable;

  • string -major,minor,patch,status, andbuild in a single String.

Thehex 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 be0x03010C.

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

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

Stringget_write_movie_path()const🔗

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


boolhas_singleton(name:StringName)const🔗

Returnstrue if a singleton with the givenname exists in the global scope. See alsoget_singleton().

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

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


boolis_editor_hint()const🔗

Returnstrue if the script is currently running inside the editor, otherwise returnsfalse. 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:

ifEngine.is_editor_hint():draw_gizmos()else:simulate_physics()

SeeRunning code in the editor in the documentation for more information.

Note: To detect whether the script is running on an editorbuild (such as when pressingF5), useOS.has_feature() with the"editor" argument instead.OS.has_feature("editor") evaluate totrue both when the script is running in the editor and when running the project from the editor, but returnsfalse when run from an exported project.


boolis_embedded_in_editor()const🔗

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


boolis_in_physics_frame()const🔗

Returnstrue 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 falsefunc_physics_process(delta):print(Engine.is_in_physics_frame())# Prints true

Errorregister_script_language(language:ScriptLanguage)🔗

Registers aScriptLanguage instance to be available withScriptServer.

Returns:


voidregister_singleton(name:StringName, instance:Object)🔗

Registers the givenObjectinstance as a singleton, available globally undername. Useful for plugins.


Errorunregister_script_language(language:ScriptLanguage)🔗

Unregisters theScriptLanguage instance fromScriptServer.

Returns:


voidunregister_singleton(name:StringName)🔗

Removes the singleton registered undername. The singleton object isnot freed. Only works with user-defined singletons registered withregister_singleton().


User-contributed notes

Please read theUser-contributed notes policy before submitting a comment.