|
@@ -19,7 +19,7 @@ Provides access to engine properties.
|
|
Description
|
|
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.
|
|
|
|
|
|
+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.
|
|
|
|
|
|
.. rst-class:: classref-reftable-group
|
|
.. rst-class:: classref-reftable-group
|
|
|
|
|
|
@@ -123,18 +123,20 @@ Property Descriptions
|
|
- |void| **set_max_fps**\ (\ value\: :ref:`int<class_int>`\ )
|
|
- |void| **set_max_fps**\ (\ value\: :ref:`int<class_int>`\ )
|
|
- :ref:`int<class_int>` **get_max_fps**\ (\ )
|
|
- :ref:`int<class_int>` **get_max_fps**\ (\ )
|
|
|
|
|
|
-The maximum number of frames per second that can be rendered. A value of ``0`` means "no limit". The actual number of frames per second may still be below this value if the CPU or GPU cannot keep up with the project logic and rendering.
|
|
|
|
|
|
+The maximum number of frames per second (FPS) that can be rendered. A value of ``0`` means the framerate is uncapped.
|
|
|
|
|
|
-Limiting the FPS can be useful to reduce system power consumption, which reduces heat and noise emissions (and improves battery life on mobile devices).
|
|
|
|
|
|
+Limiting the FPS can be useful to reduce the host machine's power consumption, which reduces heat, noise emissions, and improves battery life.
|
|
|
|
|
|
-If :ref:`ProjectSettings.display/window/vsync/vsync_mode<class_ProjectSettings_property_display/window/vsync/vsync_mode>` is ``Enabled`` or ``Adaptive``, it takes precedence and the forced FPS number cannot exceed the monitor's refresh rate.
|
|
|
|
|
|
+If :ref:`ProjectSettings.display/window/vsync/vsync_mode<class_ProjectSettings_property_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.
|
|
|
|
|
|
If :ref:`ProjectSettings.display/window/vsync/vsync_mode<class_ProjectSettings_property_display/window/vsync/vsync_mode>` is ``Enabled``, on monitors with variable refresh rate enabled (G-Sync/FreeSync), using a FPS limit a few frames lower than the monitor's refresh rate will `reduce input lag while avoiding tearing <https://blurbusters.com/howto-low-lag-vsync-on/>`__.
|
|
If :ref:`ProjectSettings.display/window/vsync/vsync_mode<class_ProjectSettings_property_display/window/vsync/vsync_mode>` is ``Enabled``, on monitors with variable refresh rate enabled (G-Sync/FreeSync), using a FPS limit a few frames lower than the monitor's refresh rate will `reduce input lag while avoiding tearing <https://blurbusters.com/howto-low-lag-vsync-on/>`__.
|
|
|
|
|
|
-If :ref:`ProjectSettings.display/window/vsync/vsync_mode<class_ProjectSettings_property_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.
|
|
|
|
-
|
|
|
|
See also :ref:`physics_ticks_per_second<class_Engine_property_physics_ticks_per_second>` and :ref:`ProjectSettings.application/run/max_fps<class_ProjectSettings_property_application/run/max_fps>`.
|
|
See also :ref:`physics_ticks_per_second<class_Engine_property_physics_ticks_per_second>` and :ref:`ProjectSettings.application/run/max_fps<class_ProjectSettings_property_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:** If :ref:`ProjectSettings.display/window/vsync/vsync_mode<class_ProjectSettings_property_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.
|
|
|
|
+
|
|
.. rst-class:: classref-item-separator
|
|
.. rst-class:: classref-item-separator
|
|
|
|
|
|
----
|
|
----
|
|
@@ -150,7 +152,9 @@ See also :ref:`physics_ticks_per_second<class_Engine_property_physics_ticks_per_
|
|
- |void| **set_max_physics_steps_per_frame**\ (\ value\: :ref:`int<class_int>`\ )
|
|
- |void| **set_max_physics_steps_per_frame**\ (\ value\: :ref:`int<class_int>`\ )
|
|
- :ref:`int<class_int>` **get_max_physics_steps_per_frame**\ (\ )
|
|
- :ref:`int<class_int>` **get_max_physics_steps_per_frame**\ (\ )
|
|
|
|
|
|
-Controls the maximum number of physics steps that can be simulated each rendered frame. The default value is tuned to avoid "spiral of death" situations where expensive physics simulations trigger 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 :ref:`physics_ticks_per_second<class_Engine_property_physics_ticks_per_second>`. This occurs even if ``delta`` is consistently used in physics calculations. To avoid this, increase :ref:`max_physics_steps_per_frame<class_Engine_property_max_physics_steps_per_frame>` if you have increased :ref:`physics_ticks_per_second<class_Engine_property_physics_ticks_per_second>` significantly above its default value.
|
|
|
|
|
|
+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 :ref:`physics_ticks_per_second<class_Engine_property_physics_ticks_per_second>`. This occurs even if ``delta`` is consistently used in physics calculations. To avoid this, increase :ref:`max_physics_steps_per_frame<class_Engine_property_max_physics_steps_per_frame>` if you have increased :ref:`physics_ticks_per_second<class_Engine_property_physics_ticks_per_second>` significantly above its default value.
|
|
|
|
|
|
.. rst-class:: classref-item-separator
|
|
.. rst-class:: classref-item-separator
|
|
|
|
|
|
@@ -167,9 +171,11 @@ Controls the maximum number of physics steps that can be simulated each rendered
|
|
- |void| **set_physics_jitter_fix**\ (\ value\: :ref:`float<class_float>`\ )
|
|
- |void| **set_physics_jitter_fix**\ (\ value\: :ref:`float<class_float>`\ )
|
|
- :ref:`float<class_float>` **get_physics_jitter_fix**\ (\ )
|
|
- :ref:`float<class_float>` **get_physics_jitter_fix**\ (\ )
|
|
|
|
|
|
-Controls how much physics ticks are synchronized with real time. For 0 or less, the ticks are synchronized. Such values are recommended for network games, where clock synchronization matters. Higher values cause higher deviation of the in-game clock and real clock but smooth out framerate jitters. The default value of 0.5 should be good enough for most; values above 2 could cause the game to react to dropped frames with a noticeable delay and are not recommended.
|
|
|
|
|
|
+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:** For best results, when using a custom physics interpolation solution, the physics jitter fix should be disabled by setting :ref:`physics_jitter_fix<class_Engine_property_physics_jitter_fix>` to ``0``.
|
|
|
|
|
|
+\ **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``.
|
|
|
|
|
|
.. rst-class:: classref-item-separator
|
|
.. rst-class:: classref-item-separator
|
|
|
|
|
|
@@ -207,10 +213,10 @@ The number of fixed iterations per second. This controls how often physics simul
|
|
|
|
|
|
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 :ref:`ProjectSettings.application/run/disable_stderr<class_ProjectSettings_property_application/run/disable_stderr>` project setting.
|
|
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 :ref:`ProjectSettings.application/run/disable_stderr<class_ProjectSettings_property_application/run/disable_stderr>` project setting.
|
|
|
|
|
|
-\ **Warning:** If you set this to ``false`` anywhere in the project, important error messages may be hidden even if they are emitted from other scripts. If this is set to ``false`` 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).
|
|
|
|
-
|
|
|
|
\ **Note:** This property does not impact the editor's Errors tab when running a project from the editor.
|
|
\ **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).
|
|
|
|
+
|
|
.. rst-class:: classref-item-separator
|
|
.. rst-class:: classref-item-separator
|
|
|
|
|
|
----
|
|
----
|
|
@@ -226,11 +232,15 @@ If ``false``, stops printing error and warning messages to the console and edito
|
|
- |void| **set_time_scale**\ (\ value\: :ref:`float<class_float>`\ )
|
|
- |void| **set_time_scale**\ (\ value\: :ref:`float<class_float>`\ )
|
|
- :ref:`float<class_float>` **get_time_scale**\ (\ )
|
|
- :ref:`float<class_float>` **get_time_scale**\ (\ )
|
|
|
|
|
|
-Controls how fast or slow the in-game clock ticks versus the real life one. It defaults to 1.0. A value of 2.0 means the game moves twice as fast as real life, whilst a value of 0.5 means the game moves at half the regular speed. This also affects :ref:`Timer<class_Timer>` and :ref:`SceneTreeTimer<class_SceneTreeTimer>` (see :ref:`SceneTree.create_timer<class_SceneTree_method_create_timer>` for how to control this).
|
|
|
|
|
|
+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 :ref:`Timer<class_Timer>`, :ref:`SceneTreeTimer<class_SceneTreeTimer>`, and all other simulations that make use of ``delta`` time (such as :ref:`Node._process<class_Node_private_method__process>` and :ref:`Node._physics_process<class_Node_private_method__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 :ref:`AudioServer.playback_speed_scale<class_AudioServer_property_playback_speed_scale>` to adjust audio playback speed independently of :ref:`time_scale<class_Engine_property_time_scale>`.
|
|
\ **Note:** This does not affect audio playback speed. Use :ref:`AudioServer.playback_speed_scale<class_AudioServer_property_playback_speed_scale>` to adjust audio playback speed independently of :ref:`time_scale<class_Engine_property_time_scale>`.
|
|
|
|
|
|
-\ **Note:** This does not automatically adjust :ref:`physics_ticks_per_second<class_Engine_property_physics_ticks_per_second>`, which means that with time scales 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 using :ref:`time_scale<class_Engine_property_time_scale>` to speed up simulation by a large factor, consider increasing :ref:`physics_ticks_per_second<class_Engine_property_physics_ticks_per_second>` as well to improve physics reliability.
|
|
|
|
|
|
+\ **Note:** This does not automatically adjust :ref:`physics_ticks_per_second<class_Engine_property_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 :ref:`time_scale<class_Engine_property_time_scale>` to speed up simulation by a large factor, consider also increasing :ref:`physics_ticks_per_second<class_Engine_property_physics_ticks_per_second>` to make the simulation more reliable.
|
|
|
|
|
|
.. rst-class:: classref-section-separator
|
|
.. rst-class:: classref-section-separator
|
|
|
|
|
|
@@ -247,9 +257,9 @@ Method Descriptions
|
|
|
|
|
|
:ref:`String<class_String>` **get_architecture_name**\ (\ ) |const|
|
|
:ref:`String<class_String>` **get_architecture_name**\ (\ ) |const|
|
|
|
|
|
|
-Returns the name of the CPU architecture the Godot binary was built for. Possible return values are ``x86_64``, ``x86_32``, ``arm64``, ``arm32``, ``rv64``, ``riscv``, ``ppc64``, ``ppc``, ``wasm64`` and ``wasm32``.
|
|
|
|
|
|
+Returns the name of the CPU architecture the Godot binary was built for. Possible return values include ``"x86_64"``, ``"x86_32"``, ``"arm64"``, ``"arm32"``, ``"rv64"``, ``"riscv"``, ``"ppc64"``, ``"ppc"``, ``"wasm64"``, and ``"wasm32"``.
|
|
|
|
|
|
-To detect whether the current CPU architecture is 64-bit, you can use the fact that all 64-bit architecture names have ``64`` in their name:
|
|
|
|
|
|
+To detect whether the current build is 64-bit, you can use the fact that all 64-bit architecture names contain ``64`` in their name:
|
|
|
|
|
|
|
|
|
|
.. tabs::
|
|
.. tabs::
|
|
@@ -270,7 +280,7 @@ To detect whether the current CPU architecture is 64-bit, you can use the fact t
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-\ **Note:** :ref:`get_architecture_name<class_Engine_method_get_architecture_name>` does *not* return the name of the host CPU architecture. For example, if running an x86_32 Godot binary on a x86_64 system, the returned value will be ``x86_32``.
|
|
|
|
|
|
+\ **Note:** This method does *not* return the name of the system's CPU architecture (like :ref:`OS.get_processor_name<class_OS_method_get_processor_name>`). For example, when running a ``x86_32`` Godot binary on a ``x86_64`` system, the returned value will still be ``"x86_32"``.
|
|
|
|
|
|
.. rst-class:: classref-item-separator
|
|
.. rst-class:: classref-item-separator
|
|
|
|
|
|
@@ -282,15 +292,7 @@ To detect whether the current CPU architecture is 64-bit, you can use the fact t
|
|
|
|
|
|
:ref:`Dictionary<class_Dictionary>` **get_author_info**\ (\ ) |const|
|
|
:ref:`Dictionary<class_Dictionary>` **get_author_info**\ (\ ) |const|
|
|
|
|
|
|
-Returns engine author information in a Dictionary.
|
|
|
|
-
|
|
|
|
-\ ``lead_developers`` - Array of Strings, lead developer names
|
|
|
|
-
|
|
|
|
-\ ``founders`` - Array of Strings, founder names
|
|
|
|
-
|
|
|
|
-\ ``project_managers`` - Array of Strings, project manager names
|
|
|
|
-
|
|
|
|
-\ ``developers`` - Array of Strings, developer names
|
|
|
|
|
|
+Returns the engine author information as a :ref:`Dictionary<class_Dictionary>`, where each entry is an :ref:`Array<class_Array>` of strings with the names of notable contributors to the Godot Engine: ``lead_developers``, ``founders``, ``project_managers``, and ``developers``.
|
|
|
|
|
|
.. rst-class:: classref-item-separator
|
|
.. rst-class:: classref-item-separator
|
|
|
|
|
|
@@ -302,11 +304,15 @@ Returns engine author information in a Dictionary.
|
|
|
|
|
|
:ref:`Array<class_Array>`\[:ref:`Dictionary<class_Dictionary>`\] **get_copyright_info**\ (\ ) |const|
|
|
:ref:`Array<class_Array>`\[:ref:`Dictionary<class_Dictionary>`\] **get_copyright_info**\ (\ ) |const|
|
|
|
|
|
|
-Returns an Array of copyright information Dictionaries.
|
|
|
|
|
|
+Returns an :ref:`Array<class_Array>` of dictionaries with copyright information for every component of Godot's source code.
|
|
|
|
+
|
|
|
|
+Every :ref:`Dictionary<class_Dictionary>` contains a ``name`` identifier, and a ``parts`` array of dictionaries. It describes the component in detail with the following entries:
|
|
|
|
+
|
|
|
|
+- ``files`` - :ref:`Array<class_Array>` of file paths from the source code affected by this component;
|
|
|
|
|
|
-\ ``name`` - String, component name
|
|
|
|
|
|
+- ``copyright`` - :ref:`Array<class_Array>` of owners of this component;
|
|
|
|
|
|
-\ ``parts`` - Array of Dictionaries {``files``, ``copyright``, ``license``} describing subsections of the component
|
|
|
|
|
|
+- ``license`` - The license applied to this component (such as "`Expat <https://en.wikipedia.org/wiki/MIT_License#Ambiguity_and_variants>`__" or "`CC-BY-4.0 <https://creativecommons.org/licenses/by/4.0/>`__").
|
|
|
|
|
|
.. rst-class:: classref-item-separator
|
|
.. rst-class:: classref-item-separator
|
|
|
|
|
|
@@ -318,7 +324,7 @@ Returns an Array of copyright information Dictionaries.
|
|
|
|
|
|
:ref:`Dictionary<class_Dictionary>` **get_donor_info**\ (\ ) |const|
|
|
:ref:`Dictionary<class_Dictionary>` **get_donor_info**\ (\ ) |const|
|
|
|
|
|
|
-Returns a Dictionary of Arrays of donor names.
|
|
|
|
|
|
+Returns a :ref:`Dictionary<class_Dictionary>` of categorized donor names. Each entry is an :ref:`Array<class_Array>` of strings:
|
|
|
|
|
|
{``platinum_sponsors``, ``gold_sponsors``, ``silver_sponsors``, ``bronze_sponsors``, ``mini_sponsors``, ``gold_donors``, ``silver_donors``, ``bronze_donors``}
|
|
{``platinum_sponsors``, ``gold_sponsors``, ``silver_sponsors``, ``bronze_sponsors``, ``mini_sponsors``, ``gold_donors``, ``silver_donors``, ``bronze_donors``}
|
|
|
|
|
|
@@ -332,7 +338,9 @@ Returns a Dictionary of Arrays of donor names.
|
|
|
|
|
|
:ref:`int<class_int>` **get_frames_drawn**\ (\ )
|
|
:ref:`int<class_int>` **get_frames_drawn**\ (\ )
|
|
|
|
|
|
-Returns the total number of frames drawn. On headless platforms, or if the render loop is disabled with ``--disable-render-loop`` via command line, :ref:`get_frames_drawn<class_Engine_method_get_frames_drawn>` always returns ``0``. See :ref:`get_process_frames<class_Engine_method_get_process_frames>`.
|
|
|
|
|
|
+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 :ref:`get_process_frames<class_Engine_method_get_process_frames>`.
|
|
|
|
|
|
.. rst-class:: classref-item-separator
|
|
.. rst-class:: classref-item-separator
|
|
|
|
|
|
@@ -344,7 +352,7 @@ Returns the total number of frames drawn. On headless platforms, or if the rende
|
|
|
|
|
|
:ref:`float<class_float>` **get_frames_per_second**\ (\ ) |const|
|
|
:ref:`float<class_float>` **get_frames_per_second**\ (\ ) |const|
|
|
|
|
|
|
-Returns the frames per second of the running game.
|
|
|
|
|
|
+Returns the average frames rendered every second (FPS), also known as the framerate.
|
|
|
|
|
|
.. rst-class:: classref-item-separator
|
|
.. rst-class:: classref-item-separator
|
|
|
|
|
|
@@ -356,7 +364,7 @@ Returns the frames per second of the running game.
|
|
|
|
|
|
:ref:`Dictionary<class_Dictionary>` **get_license_info**\ (\ ) |const|
|
|
:ref:`Dictionary<class_Dictionary>` **get_license_info**\ (\ ) |const|
|
|
|
|
|
|
-Returns Dictionary of licenses used by Godot and included third party components.
|
|
|
|
|
|
+Returns a :ref:`Dictionary<class_Dictionary>` of licenses used by Godot and included third party components. Each entry is a license name (such as "`Expat <https://en.wikipedia.org/wiki/MIT_License#Ambiguity_and_variants>`__") and its associated text.
|
|
|
|
|
|
.. rst-class:: classref-item-separator
|
|
.. rst-class:: classref-item-separator
|
|
|
|
|
|
@@ -368,7 +376,7 @@ Returns Dictionary of licenses used by Godot and included third party components
|
|
|
|
|
|
:ref:`String<class_String>` **get_license_text**\ (\ ) |const|
|
|
:ref:`String<class_String>` **get_license_text**\ (\ ) |const|
|
|
|
|
|
|
-Returns Godot license text.
|
|
|
|
|
|
+Returns the full Godot license text.
|
|
|
|
|
|
.. rst-class:: classref-item-separator
|
|
.. rst-class:: classref-item-separator
|
|
|
|
|
|
@@ -380,7 +388,9 @@ Returns Godot license text.
|
|
|
|
|
|
:ref:`MainLoop<class_MainLoop>` **get_main_loop**\ (\ ) |const|
|
|
:ref:`MainLoop<class_MainLoop>` **get_main_loop**\ (\ ) |const|
|
|
|
|
|
|
-Returns the main loop object (see :ref:`MainLoop<class_MainLoop>` and :ref:`SceneTree<class_SceneTree>`).
|
|
|
|
|
|
+Returns the instance of the :ref:`MainLoop<class_MainLoop>`. This is usually the main :ref:`SceneTree<class_SceneTree>` and is the same as :ref:`Node.get_tree<class_Node_method_get_tree>`.
|
|
|
|
+
|
|
|
|
+\ **Note:** The type instantiated as the main loop can changed with :ref:`ProjectSettings.application/run/main_loop_type<class_ProjectSettings_property_application/run/main_loop_type>`.
|
|
|
|
|
|
.. rst-class:: classref-item-separator
|
|
.. rst-class:: classref-item-separator
|
|
|
|
|
|
@@ -392,9 +402,9 @@ Returns the main loop object (see :ref:`MainLoop<class_MainLoop>` and :ref:`Scen
|
|
|
|
|
|
:ref:`int<class_int>` **get_physics_frames**\ (\ ) |const|
|
|
:ref:`int<class_int>` **get_physics_frames**\ (\ ) |const|
|
|
|
|
|
|
-Returns the total number of frames passed since engine initialization which is advanced on each **physics frame**. See also :ref:`get_process_frames<class_Engine_method_get_process_frames>`.
|
|
|
|
|
|
+Returns the total number of frames passed since the engine started. This number is increased every **physics frame**. See also :ref:`get_process_frames<class_Engine_method_get_process_frames>`.
|
|
|
|
|
|
-\ :ref:`get_physics_frames<class_Engine_method_get_physics_frames>` can be used to run expensive logic less often without relying on a :ref:`Timer<class_Timer>`:
|
|
|
|
|
|
+This method can be used to run expensive logic less often without relying on a :ref:`Timer<class_Timer>`:
|
|
|
|
|
|
|
|
|
|
.. tabs::
|
|
.. tabs::
|
|
@@ -403,7 +413,7 @@ Returns the total number of frames passed since engine initialization which is a
|
|
|
|
|
|
func _physics_process(_delta):
|
|
func _physics_process(_delta):
|
|
if Engine.get_physics_frames() % 2 == 0:
|
|
if Engine.get_physics_frames() % 2 == 0:
|
|
- pass # Run expensive logic only once every 2 physics frames here.
|
|
|
|
|
|
+ pass # Run expensive logic only once every 2 physics frames here.
|
|
|
|
|
|
.. code-tab:: csharp
|
|
.. code-tab:: csharp
|
|
|
|
|
|
@@ -441,9 +451,9 @@ Returns the fraction through the current physics tick we are at the time of rend
|
|
|
|
|
|
:ref:`int<class_int>` **get_process_frames**\ (\ ) |const|
|
|
:ref:`int<class_int>` **get_process_frames**\ (\ ) |const|
|
|
|
|
|
|
-Returns the total number of frames passed since engine initialization which is advanced on each **process frame**, regardless of whether the render loop is enabled. See also :ref:`get_frames_drawn<class_Engine_method_get_frames_drawn>` and :ref:`get_physics_frames<class_Engine_method_get_physics_frames>`.
|
|
|
|
|
|
+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 :ref:`get_frames_drawn<class_Engine_method_get_frames_drawn>` and :ref:`get_physics_frames<class_Engine_method_get_physics_frames>`.
|
|
|
|
|
|
-\ :ref:`get_process_frames<class_Engine_method_get_process_frames>` can be used to run expensive logic less often without relying on a :ref:`Timer<class_Timer>`:
|
|
|
|
|
|
+This method can be used to run expensive logic less often without relying on a :ref:`Timer<class_Timer>`:
|
|
|
|
|
|
|
|
|
|
.. tabs::
|
|
.. tabs::
|
|
@@ -451,8 +461,8 @@ Returns the total number of frames passed since engine initialization which is a
|
|
.. code-tab:: gdscript
|
|
.. code-tab:: gdscript
|
|
|
|
|
|
func _process(_delta):
|
|
func _process(_delta):
|
|
- if Engine.get_process_frames() % 2 == 0:
|
|
|
|
- pass # Run expensive logic only once every 2 process (render) frames here.
|
|
|
|
|
|
+ if Engine.get_process_frames() % 5 == 0:
|
|
|
|
+ pass # Run expensive logic only once every 5 process (render) frames here.
|
|
|
|
|
|
.. code-tab:: csharp
|
|
.. code-tab:: csharp
|
|
|
|
|
|
@@ -460,9 +470,9 @@ Returns the total number of frames passed since engine initialization which is a
|
|
{
|
|
{
|
|
base._Process(delta);
|
|
base._Process(delta);
|
|
|
|
|
|
- if (Engine.GetProcessFrames() % 2 == 0)
|
|
|
|
|
|
+ if (Engine.GetProcessFrames() % 5 == 0)
|
|
{
|
|
{
|
|
- // Run expensive logic only once every 2 physics frames here.
|
|
|
|
|
|
+ // Run expensive logic only once every 5 process (render) frames here.
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -478,7 +488,7 @@ Returns the total number of frames passed since engine initialization which is a
|
|
|
|
|
|
:ref:`ScriptLanguage<class_ScriptLanguage>` **get_script_language**\ (\ index\: :ref:`int<class_int>`\ ) |const|
|
|
:ref:`ScriptLanguage<class_ScriptLanguage>` **get_script_language**\ (\ index\: :ref:`int<class_int>`\ ) |const|
|
|
|
|
|
|
-Returns an instance of a :ref:`ScriptLanguage<class_ScriptLanguage>` with the given index.
|
|
|
|
|
|
+Returns an instance of a :ref:`ScriptLanguage<class_ScriptLanguage>` with the given ``index``.
|
|
|
|
|
|
.. rst-class:: classref-item-separator
|
|
.. rst-class:: classref-item-separator
|
|
|
|
|
|
@@ -502,7 +512,9 @@ Returns the number of available script languages. Use with :ref:`get_script_lang
|
|
|
|
|
|
:ref:`Object<class_Object>` **get_singleton**\ (\ name\: :ref:`StringName<class_StringName>`\ ) |const|
|
|
:ref:`Object<class_Object>` **get_singleton**\ (\ name\: :ref:`StringName<class_StringName>`\ ) |const|
|
|
|
|
|
|
-Returns a global singleton with given ``name``. Often used for plugins, e.g. GodotPayments.
|
|
|
|
|
|
+Returns the global singleton with the given ``name``, or ``null`` if it does not exist. Often used for plugins. See also :ref:`has_singleton<class_Engine_method_has_singleton>` and :ref:`get_singleton_list<class_Engine_method_get_singleton_list>`.
|
|
|
|
+
|
|
|
|
+\ **Note:** Global singletons are not the same as autoloaded nodes, which are configurable in the project settings.
|
|
|
|
|
|
.. rst-class:: classref-item-separator
|
|
.. rst-class:: classref-item-separator
|
|
|
|
|
|
@@ -514,7 +526,7 @@ Returns a global singleton with given ``name``. Often used for plugins, e.g. God
|
|
|
|
|
|
:ref:`PackedStringArray<class_PackedStringArray>` **get_singleton_list**\ (\ ) |const|
|
|
:ref:`PackedStringArray<class_PackedStringArray>` **get_singleton_list**\ (\ ) |const|
|
|
|
|
|
|
-Returns a list of available global singletons.
|
|
|
|
|
|
+Returns a list of names of all available global singletons. See also :ref:`get_singleton<class_Engine_method_get_singleton>`.
|
|
|
|
|
|
.. rst-class:: classref-item-separator
|
|
.. rst-class:: classref-item-separator
|
|
|
|
|
|
@@ -526,45 +538,49 @@ Returns a list of available global singletons.
|
|
|
|
|
|
:ref:`Dictionary<class_Dictionary>` **get_version_info**\ (\ ) |const|
|
|
:ref:`Dictionary<class_Dictionary>` **get_version_info**\ (\ ) |const|
|
|
|
|
|
|
-Returns the current engine version information in a Dictionary.
|
|
|
|
|
|
+Returns the current engine version information as a :ref:`Dictionary<class_Dictionary>` containing the following entries:
|
|
|
|
|
|
-\ ``major`` - Holds the major version number as an int
|
|
|
|
|
|
+- ``major`` - Major version number as an int;
|
|
|
|
|
|
-\ ``minor`` - Holds the minor version number as an int
|
|
|
|
|
|
+- ``minor`` - Minor version number as an int;
|
|
|
|
|
|
-\ ``patch`` - Holds the patch version number as an int
|
|
|
|
|
|
+- ``patch`` - Patch version number as an int;
|
|
|
|
|
|
-\ ``hex`` - Holds the full version number encoded as a hexadecimal int with one byte (2 places) per number (see example below)
|
|
|
|
|
|
+- ``hex`` - Full version encoded as a hexadecimal int with one byte (2 hex digits) per number (see example below);
|
|
|
|
|
|
-\ ``status`` - Holds the status (e.g. "beta", "rc1", "rc2", ... "stable") as a String
|
|
|
|
|
|
+- ``status`` - Status (such as "beta", "rc1", "rc2", "stable", etc.) as a String;
|
|
|
|
|
|
-\ ``build`` - Holds the build name (e.g. "custom_build") as a String
|
|
|
|
|
|
+- ``build`` - Build name (e.g. "custom_build") as a String;
|
|
|
|
|
|
-\ ``hash`` - Holds the full Git commit hash as a String
|
|
|
|
|
|
+- ``hash`` - Full Git commit hash as a String;
|
|
|
|
|
|
-\ ``string`` - ``major`` + ``minor`` + ``patch`` + ``status`` + ``build`` in a single String
|
|
|
|
|
|
+- ``timestamp`` - Holds the Git commit date UNIX timestamp in seconds as an int, or ``0`` if unavailable;
|
|
|
|
|
|
-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:** It's still an int internally, and printing it will give you its decimal representation, which is not particularly meaningful. Use hexadecimal literals for easy version comparisons from code:
|
|
|
|
|
|
+- ``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 :ref:`int<class_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:
|
|
|
|
|
|
|
|
|
|
.. tabs::
|
|
.. tabs::
|
|
|
|
|
|
.. code-tab:: gdscript
|
|
.. code-tab:: gdscript
|
|
|
|
|
|
- if Engine.get_version_info().hex >= 0x030200:
|
|
|
|
- # Do things specific to version 3.2 or later
|
|
|
|
|
|
+ if Engine.get_version_info().hex >= 0x040100:
|
|
|
|
+ pass # Do things specific to version 4.1 or later.
|
|
else:
|
|
else:
|
|
- # Do things specific to versions before 3.2
|
|
|
|
|
|
+ pass # Do things specific to versions before 4.1.
|
|
|
|
|
|
.. code-tab:: csharp
|
|
.. code-tab:: csharp
|
|
|
|
|
|
- if ((int)Engine.GetVersionInfo()["hex"] >= 0x030200)
|
|
|
|
|
|
+ if ((int)Engine.GetVersionInfo()["hex"] >= 0x040100)
|
|
{
|
|
{
|
|
- // Do things specific to version 3.2 or later
|
|
|
|
|
|
+ // Do things specific to version 4.1 or later.
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
- // Do things specific to versions before 3.2
|
|
|
|
|
|
+ // Do things specific to versions before 4.1.
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -579,7 +595,7 @@ The ``hex`` value is encoded as follows, from left to right: one byte for the ma
|
|
|
|
|
|
:ref:`String<class_String>` **get_write_movie_path**\ (\ ) |const|
|
|
:ref:`String<class_String>` **get_write_movie_path**\ (\ ) |const|
|
|
|
|
|
|
-Returns the path to the :ref:`MovieWriter<class_MovieWriter>`'s output file, or an empty string if the engine wasn't started in Movie Maker mode. This path can be absolute or relative depending on how the user specified it.
|
|
|
|
|
|
+Returns the path to the :ref:`MovieWriter<class_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 :ref:`ProjectSettings.editor/movie_writer/movie_file<class_ProjectSettings_property_editor/movie_writer/movie_file>`.
|
|
|
|
|
|
.. rst-class:: classref-item-separator
|
|
.. rst-class:: classref-item-separator
|
|
|
|
|
|
@@ -591,7 +607,28 @@ Returns the path to the :ref:`MovieWriter<class_MovieWriter>`'s output file, or
|
|
|
|
|
|
:ref:`bool<class_bool>` **has_singleton**\ (\ name\: :ref:`StringName<class_StringName>`\ ) |const|
|
|
:ref:`bool<class_bool>` **has_singleton**\ (\ name\: :ref:`StringName<class_StringName>`\ ) |const|
|
|
|
|
|
|
-Returns ``true`` if a singleton with given ``name`` exists in global scope.
|
|
|
|
|
|
+Returns ``true`` if a singleton with the given ``name`` exists in the global scope. See also :ref:`get_singleton<class_Engine_method_get_singleton>`.
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+.. tabs::
|
|
|
|
+
|
|
|
|
+ .. code-tab:: gdscript
|
|
|
|
+
|
|
|
|
+ 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
|
|
|
|
+
|
|
|
|
+ .. code-tab:: csharp
|
|
|
|
+
|
|
|
|
+ GD.Print(Engine.HasSingleton("OS")); // Prints true
|
|
|
|
+ GD.Print(Engine.HasSingleton("Engine")); // Prints true
|
|
|
|
+ GD.Print(Engine.HasSingleton("AudioServer")); // Prints true
|
|
|
|
+ GD.Print(Engine.HasSingleton("Unknown")); // Prints false
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+\ **Note:** Global singletons are not the same as autoloaded nodes, which are configurable in the project settings.
|
|
|
|
|
|
.. rst-class:: classref-item-separator
|
|
.. rst-class:: classref-item-separator
|
|
|
|
|
|
@@ -603,7 +640,7 @@ Returns ``true`` if a singleton with given ``name`` exists in global scope.
|
|
|
|
|
|
:ref:`bool<class_bool>` **is_editor_hint**\ (\ ) |const|
|
|
:ref:`bool<class_bool>` **is_editor_hint**\ (\ ) |const|
|
|
|
|
|
|
-Returns ``true`` if the script is currently running inside the editor, ``false`` otherwise. 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:
|
|
|
|
|
|
+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:
|
|
|
|
|
|
|
|
|
|
.. tabs::
|
|
.. tabs::
|
|
@@ -626,7 +663,7 @@ Returns ``true`` if the script is currently running inside the editor, ``false``
|
|
|
|
|
|
See :doc:`Running code in the editor <../tutorials/plugins/running_code_in_the_editor>` in the documentation for more information.
|
|
See :doc:`Running code in the editor <../tutorials/plugins/running_code_in_the_editor>` in the documentation for more information.
|
|
|
|
|
|
-\ **Note:** To detect whether the script is run from an editor *build* (e.g. when pressing :kbd:`F5`), use :ref:`OS.has_feature<class_OS_method_has_feature>` with the ``"editor"`` argument instead. ``OS.has_feature("editor")`` will evaluate to ``true`` both when the code is running in the editor and when running the project from the editor, but it will evaluate to ``false`` when the code is run from an exported project.
|
|
|
|
|
|
+\ **Note:** To detect whether the script is running on an editor *build* (such as when pressing :kbd:`F5`), use :ref:`OS.has_feature<class_OS_method_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.
|
|
|
|
|
|
.. rst-class:: classref-item-separator
|
|
.. rst-class:: classref-item-separator
|
|
|
|
|
|
@@ -638,7 +675,20 @@ See :doc:`Running code in the editor <../tutorials/plugins/running_code_in_the_e
|
|
|
|
|
|
:ref:`bool<class_bool>` **is_in_physics_frame**\ (\ ) |const|
|
|
:ref:`bool<class_bool>` **is_in_physics_frame**\ (\ ) |const|
|
|
|
|
|
|
-Returns ``true`` if the game is inside the fixed process and physics phase of the game loop.
|
|
|
|
|
|
+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
|
|
|
|
|
|
.. rst-class:: classref-item-separator
|
|
.. rst-class:: classref-item-separator
|
|
|
|
|
|
@@ -654,11 +704,11 @@ Registers a :ref:`ScriptLanguage<class_ScriptLanguage>` instance to be available
|
|
|
|
|
|
Returns:
|
|
Returns:
|
|
|
|
|
|
-- :ref:`@GlobalScope.OK<class_@GlobalScope_constant_OK>` on success
|
|
|
|
|
|
+- :ref:`@GlobalScope.OK<class_@GlobalScope_constant_OK>` on success;
|
|
|
|
|
|
-- :ref:`@GlobalScope.ERR_UNAVAILABLE<class_@GlobalScope_constant_ERR_UNAVAILABLE>` if ``ScriptServer`` has reached it limit and cannot register any new language
|
|
|
|
|
|
+- :ref:`@GlobalScope.ERR_UNAVAILABLE<class_@GlobalScope_constant_ERR_UNAVAILABLE>` if ``ScriptServer`` has reached the limit and cannot register any new language;
|
|
|
|
|
|
-- :ref:`@GlobalScope.ERR_ALREADY_EXISTS<class_@GlobalScope_constant_ERR_ALREADY_EXISTS>` if ``ScriptServer`` already contains a language with similar extension/name/type
|
|
|
|
|
|
+- :ref:`@GlobalScope.ERR_ALREADY_EXISTS<class_@GlobalScope_constant_ERR_ALREADY_EXISTS>` if ``ScriptServer`` already contains a language with similar extension/name/type.
|
|
|
|
|
|
.. rst-class:: classref-item-separator
|
|
.. rst-class:: classref-item-separator
|
|
|
|
|
|
@@ -670,7 +720,7 @@ Returns:
|
|
|
|
|
|
|void| **register_singleton**\ (\ name\: :ref:`StringName<class_StringName>`, instance\: :ref:`Object<class_Object>`\ )
|
|
|void| **register_singleton**\ (\ name\: :ref:`StringName<class_StringName>`, instance\: :ref:`Object<class_Object>`\ )
|
|
|
|
|
|
-Registers the given object as a singleton, globally available under ``name``.
|
|
|
|
|
|
+Registers the given :ref:`Object<class_Object>` ``instance`` as a singleton, available globally under ``name``. Useful for plugins.
|
|
|
|
|
|
.. rst-class:: classref-item-separator
|
|
.. rst-class:: classref-item-separator
|
|
|
|
|
|
@@ -686,9 +736,9 @@ Unregisters the :ref:`ScriptLanguage<class_ScriptLanguage>` instance from ``Scri
|
|
|
|
|
|
Returns:
|
|
Returns:
|
|
|
|
|
|
-- :ref:`@GlobalScope.OK<class_@GlobalScope_constant_OK>` on success
|
|
|
|
|
|
+- :ref:`@GlobalScope.OK<class_@GlobalScope_constant_OK>` on success;
|
|
|
|
|
|
-- :ref:`@GlobalScope.ERR_DOES_NOT_EXIST<class_@GlobalScope_constant_ERR_DOES_NOT_EXIST>` if the language is already not registered in ``ScriptServer``
|
|
|
|
|
|
+- :ref:`@GlobalScope.ERR_DOES_NOT_EXIST<class_@GlobalScope_constant_ERR_DOES_NOT_EXIST>` if the language is not registered in ``ScriptServer``.
|
|
|
|
|
|
.. rst-class:: classref-item-separator
|
|
.. rst-class:: classref-item-separator
|
|
|
|
|
|
@@ -700,7 +750,7 @@ Returns:
|
|
|
|
|
|
|void| **unregister_singleton**\ (\ name\: :ref:`StringName<class_StringName>`\ )
|
|
|void| **unregister_singleton**\ (\ name\: :ref:`StringName<class_StringName>`\ )
|
|
|
|
|
|
-Unregisters the singleton registered under ``name``. The singleton object is not freed. Only works with user-defined singletons created with :ref:`register_singleton<class_Engine_method_register_singleton>`.
|
|
|
|
|
|
+Removes the singleton registered under ``name``. The singleton object is *not* freed. Only works with user-defined singletons registered with :ref:`register_singleton<class_Engine_method_register_singleton>`.
|
|
|
|
|
|
.. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
|
|
.. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
|
|
.. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
|
|
.. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
|