class_engine.rst 46 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800
  1. :github_url: hide
  2. .. DO NOT EDIT THIS FILE!!!
  3. .. Generated automatically from Godot engine sources.
  4. .. Generator: https://github.com/godotengine/godot/tree/master/doc/tools/make_rst.py.
  5. .. XML source: https://github.com/godotengine/godot/tree/master/doc/classes/Engine.xml.
  6. .. _class_Engine:
  7. Engine
  8. ======
  9. **Inherits:** :ref:`Object<class_Object>`
  10. Provides access to engine properties.
  11. .. rst-class:: classref-introduction-group
  12. Description
  13. -----------
  14. 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.
  15. .. rst-class:: classref-reftable-group
  16. Properties
  17. ----------
  18. .. table::
  19. :widths: auto
  20. +---------------------------+---------------------------------------------------------------------------------------+----------+
  21. | :ref:`int<class_int>` | :ref:`max_fps<class_Engine_property_max_fps>` | ``0`` |
  22. +---------------------------+---------------------------------------------------------------------------------------+----------+
  23. | :ref:`int<class_int>` | :ref:`max_physics_steps_per_frame<class_Engine_property_max_physics_steps_per_frame>` | ``8`` |
  24. +---------------------------+---------------------------------------------------------------------------------------+----------+
  25. | :ref:`float<class_float>` | :ref:`physics_jitter_fix<class_Engine_property_physics_jitter_fix>` | ``0.5`` |
  26. +---------------------------+---------------------------------------------------------------------------------------+----------+
  27. | :ref:`int<class_int>` | :ref:`physics_ticks_per_second<class_Engine_property_physics_ticks_per_second>` | ``60`` |
  28. +---------------------------+---------------------------------------------------------------------------------------+----------+
  29. | :ref:`bool<class_bool>` | :ref:`print_error_messages<class_Engine_property_print_error_messages>` | ``true`` |
  30. +---------------------------+---------------------------------------------------------------------------------------+----------+
  31. | :ref:`bool<class_bool>` | :ref:`print_to_stdout<class_Engine_property_print_to_stdout>` | ``true`` |
  32. +---------------------------+---------------------------------------------------------------------------------------+----------+
  33. | :ref:`float<class_float>` | :ref:`time_scale<class_Engine_property_time_scale>` | ``1.0`` |
  34. +---------------------------+---------------------------------------------------------------------------------------+----------+
  35. .. rst-class:: classref-reftable-group
  36. Methods
  37. -------
  38. .. table::
  39. :widths: auto
  40. +----------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------+
  41. | :ref:`Array<class_Array>`\[:ref:`ScriptBacktrace<class_ScriptBacktrace>`\] | :ref:`capture_script_backtraces<class_Engine_method_capture_script_backtraces>`\ (\ include_variables\: :ref:`bool<class_bool>` = false\ ) |const| |
  42. +----------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------+
  43. | :ref:`String<class_String>` | :ref:`get_architecture_name<class_Engine_method_get_architecture_name>`\ (\ ) |const| |
  44. +----------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------+
  45. | :ref:`Dictionary<class_Dictionary>` | :ref:`get_author_info<class_Engine_method_get_author_info>`\ (\ ) |const| |
  46. +----------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------+
  47. | :ref:`Array<class_Array>`\[:ref:`Dictionary<class_Dictionary>`\] | :ref:`get_copyright_info<class_Engine_method_get_copyright_info>`\ (\ ) |const| |
  48. +----------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------+
  49. | :ref:`Dictionary<class_Dictionary>` | :ref:`get_donor_info<class_Engine_method_get_donor_info>`\ (\ ) |const| |
  50. +----------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------+
  51. | :ref:`int<class_int>` | :ref:`get_frames_drawn<class_Engine_method_get_frames_drawn>`\ (\ ) |
  52. +----------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------+
  53. | :ref:`float<class_float>` | :ref:`get_frames_per_second<class_Engine_method_get_frames_per_second>`\ (\ ) |const| |
  54. +----------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------+
  55. | :ref:`Dictionary<class_Dictionary>` | :ref:`get_license_info<class_Engine_method_get_license_info>`\ (\ ) |const| |
  56. +----------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------+
  57. | :ref:`String<class_String>` | :ref:`get_license_text<class_Engine_method_get_license_text>`\ (\ ) |const| |
  58. +----------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------+
  59. | :ref:`MainLoop<class_MainLoop>` | :ref:`get_main_loop<class_Engine_method_get_main_loop>`\ (\ ) |const| |
  60. +----------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------+
  61. | :ref:`int<class_int>` | :ref:`get_physics_frames<class_Engine_method_get_physics_frames>`\ (\ ) |const| |
  62. +----------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------+
  63. | :ref:`float<class_float>` | :ref:`get_physics_interpolation_fraction<class_Engine_method_get_physics_interpolation_fraction>`\ (\ ) |const| |
  64. +----------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------+
  65. | :ref:`int<class_int>` | :ref:`get_process_frames<class_Engine_method_get_process_frames>`\ (\ ) |const| |
  66. +----------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------+
  67. | :ref:`ScriptLanguage<class_ScriptLanguage>` | :ref:`get_script_language<class_Engine_method_get_script_language>`\ (\ index\: :ref:`int<class_int>`\ ) |const| |
  68. +----------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------+
  69. | :ref:`int<class_int>` | :ref:`get_script_language_count<class_Engine_method_get_script_language_count>`\ (\ ) |
  70. +----------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------+
  71. | :ref:`Object<class_Object>` | :ref:`get_singleton<class_Engine_method_get_singleton>`\ (\ name\: :ref:`StringName<class_StringName>`\ ) |const| |
  72. +----------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------+
  73. | :ref:`PackedStringArray<class_PackedStringArray>` | :ref:`get_singleton_list<class_Engine_method_get_singleton_list>`\ (\ ) |const| |
  74. +----------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------+
  75. | :ref:`Dictionary<class_Dictionary>` | :ref:`get_version_info<class_Engine_method_get_version_info>`\ (\ ) |const| |
  76. +----------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------+
  77. | :ref:`String<class_String>` | :ref:`get_write_movie_path<class_Engine_method_get_write_movie_path>`\ (\ ) |const| |
  78. +----------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------+
  79. | :ref:`bool<class_bool>` | :ref:`has_singleton<class_Engine_method_has_singleton>`\ (\ name\: :ref:`StringName<class_StringName>`\ ) |const| |
  80. +----------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------+
  81. | :ref:`bool<class_bool>` | :ref:`is_editor_hint<class_Engine_method_is_editor_hint>`\ (\ ) |const| |
  82. +----------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------+
  83. | :ref:`bool<class_bool>` | :ref:`is_embedded_in_editor<class_Engine_method_is_embedded_in_editor>`\ (\ ) |const| |
  84. +----------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------+
  85. | :ref:`bool<class_bool>` | :ref:`is_in_physics_frame<class_Engine_method_is_in_physics_frame>`\ (\ ) |const| |
  86. +----------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------+
  87. | :ref:`Error<enum_@GlobalScope_Error>` | :ref:`register_script_language<class_Engine_method_register_script_language>`\ (\ language\: :ref:`ScriptLanguage<class_ScriptLanguage>`\ ) |
  88. +----------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------+
  89. | |void| | :ref:`register_singleton<class_Engine_method_register_singleton>`\ (\ name\: :ref:`StringName<class_StringName>`, instance\: :ref:`Object<class_Object>`\ ) |
  90. +----------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------+
  91. | :ref:`Error<enum_@GlobalScope_Error>` | :ref:`unregister_script_language<class_Engine_method_unregister_script_language>`\ (\ language\: :ref:`ScriptLanguage<class_ScriptLanguage>`\ ) |
  92. +----------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------+
  93. | |void| | :ref:`unregister_singleton<class_Engine_method_unregister_singleton>`\ (\ name\: :ref:`StringName<class_StringName>`\ ) |
  94. +----------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------+
  95. .. rst-class:: classref-section-separator
  96. ----
  97. .. rst-class:: classref-descriptions-group
  98. Property Descriptions
  99. ---------------------
  100. .. _class_Engine_property_max_fps:
  101. .. rst-class:: classref-property
  102. :ref:`int<class_int>` **max_fps** = ``0`` :ref:`๐Ÿ”—<class_Engine_property_max_fps>`
  103. .. rst-class:: classref-property-setget
  104. - |void| **set_max_fps**\ (\ value\: :ref:`int<class_int>`\ )
  105. - :ref:`int<class_int>` **get_max_fps**\ (\ )
  106. The maximum number of frames that can be rendered every second (FPS). A value of ``0`` means the framerate is uncapped.
  107. Limiting the FPS can be useful to reduce the host machine's power consumption, which reduces heat, noise emissions, and improves battery life.
  108. 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.
  109. 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 an 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/>`__.
  110. 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>`.
  111. \ **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.
  112. \ **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.
  113. .. rst-class:: classref-item-separator
  114. ----
  115. .. _class_Engine_property_max_physics_steps_per_frame:
  116. .. rst-class:: classref-property
  117. :ref:`int<class_int>` **max_physics_steps_per_frame** = ``8`` :ref:`๐Ÿ”—<class_Engine_property_max_physics_steps_per_frame>`
  118. .. rst-class:: classref-property-setget
  119. - |void| **set_max_physics_steps_per_frame**\ (\ value\: :ref:`int<class_int>`\ )
  120. - :ref:`int<class_int>` **get_max_physics_steps_per_frame**\ (\ )
  121. The maximum number of physics steps that can be simulated each rendered frame.
  122. \ **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.
  123. .. rst-class:: classref-item-separator
  124. ----
  125. .. _class_Engine_property_physics_jitter_fix:
  126. .. rst-class:: classref-property
  127. :ref:`float<class_float>` **physics_jitter_fix** = ``0.5`` :ref:`๐Ÿ”—<class_Engine_property_physics_jitter_fix>`
  128. .. rst-class:: classref-property-setget
  129. - |void| **set_physics_jitter_fix**\ (\ value\: :ref:`float<class_float>`\ )
  130. - :ref:`float<class_float>` **get_physics_jitter_fix**\ (\ )
  131. 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.
  132. \ **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.
  133. \ **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``.
  134. .. rst-class:: classref-item-separator
  135. ----
  136. .. _class_Engine_property_physics_ticks_per_second:
  137. .. rst-class:: classref-property
  138. :ref:`int<class_int>` **physics_ticks_per_second** = ``60`` :ref:`๐Ÿ”—<class_Engine_property_physics_ticks_per_second>`
  139. .. rst-class:: classref-property-setget
  140. - |void| **set_physics_ticks_per_second**\ (\ value\: :ref:`int<class_int>`\ )
  141. - :ref:`int<class_int>` **get_physics_ticks_per_second**\ (\ )
  142. The number of fixed iterations per second. This controls how often physics simulation and :ref:`Node._physics_process()<class_Node_private_method__physics_process>` methods are run. This value should generally always be set to ``60`` or above, as Godot doesn't interpolate the physics step. As a result, values lower than ``60`` 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 also :ref:`max_fps<class_Engine_property_max_fps>` and :ref:`ProjectSettings.physics/common/physics_ticks_per_second<class_ProjectSettings_property_physics/common/physics_ticks_per_second>`.
  143. \ **Note:** Only :ref:`max_physics_steps_per_frame<class_Engine_property_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 :ref:`max_physics_steps_per_frame<class_Engine_property_max_physics_steps_per_frame>` if increasing :ref:`physics_ticks_per_second<class_Engine_property_physics_ticks_per_second>` significantly above its default value.
  144. .. rst-class:: classref-item-separator
  145. ----
  146. .. _class_Engine_property_print_error_messages:
  147. .. rst-class:: classref-property
  148. :ref:`bool<class_bool>` **print_error_messages** = ``true`` :ref:`๐Ÿ”—<class_Engine_property_print_error_messages>`
  149. .. rst-class:: classref-property-setget
  150. - |void| **set_print_error_messages**\ (\ value\: :ref:`bool<class_bool>`\ )
  151. - :ref:`bool<class_bool>` **is_printing_error_messages**\ (\ )
  152. 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.
  153. \ **Note:** This property does not impact the editor's Errors tab when running a project from the editor.
  154. \ **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).
  155. .. rst-class:: classref-item-separator
  156. ----
  157. .. _class_Engine_property_print_to_stdout:
  158. .. rst-class:: classref-property
  159. :ref:`bool<class_bool>` **print_to_stdout** = ``true`` :ref:`๐Ÿ”—<class_Engine_property_print_to_stdout>`
  160. .. rst-class:: classref-property-setget
  161. - |void| **set_print_to_stdout**\ (\ value\: :ref:`bool<class_bool>`\ )
  162. - :ref:`bool<class_bool>` **is_printing_to_stdout**\ (\ )
  163. If ``false``, stops printing messages (for example using :ref:`@GlobalScope.print()<class_@GlobalScope_method_print>`) to the console, log files, and editor Output log. This property is equivalent to the :ref:`ProjectSettings.application/run/disable_stdout<class_ProjectSettings_property_application/run/disable_stdout>` project setting.
  164. \ **Note:** This does not stop printing errors or warnings produced by scripts to the console or log files, for more details see :ref:`print_error_messages<class_Engine_property_print_error_messages>`.
  165. .. rst-class:: classref-item-separator
  166. ----
  167. .. _class_Engine_property_time_scale:
  168. .. rst-class:: classref-property
  169. :ref:`float<class_float>` **time_scale** = ``1.0`` :ref:`๐Ÿ”—<class_Engine_property_time_scale>`
  170. .. rst-class:: classref-property-setget
  171. - |void| **set_time_scale**\ (\ value\: :ref:`float<class_float>`\ )
  172. - :ref:`float<class_float>` **get_time_scale**\ (\ )
  173. 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.
  174. 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>`).
  175. \ **Note:** It's recommended to keep this property above ``0.0``, as the game may behave unexpectedly otherwise.
  176. \ **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>`.
  177. \ **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.
  178. .. rst-class:: classref-section-separator
  179. ----
  180. .. rst-class:: classref-descriptions-group
  181. Method Descriptions
  182. -------------------
  183. .. _class_Engine_method_capture_script_backtraces:
  184. .. rst-class:: classref-method
  185. :ref:`Array<class_Array>`\[:ref:`ScriptBacktrace<class_ScriptBacktrace>`\] **capture_script_backtraces**\ (\ include_variables\: :ref:`bool<class_bool>` = false\ ) |const| :ref:`๐Ÿ”—<class_Engine_method_capture_script_backtraces>`
  186. Captures and returns backtraces from all registered script languages.
  187. By default, the returned :ref:`ScriptBacktrace<class_ScriptBacktrace>` will only contain stack frames in editor builds and debug builds. To enable them for release builds as well, you need to enable :ref:`ProjectSettings.debug/settings/gdscript/always_track_call_stacks<class_ProjectSettings_property_debug/settings/gdscript/always_track_call_stacks>`.
  188. 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 :ref:`ProjectSettings.debug/settings/gdscript/always_track_local_variables<class_ProjectSettings_property_debug/settings/gdscript/always_track_local_variables>`.
  189. \ **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 :ref:`ScriptBacktrace<class_ScriptBacktrace>` will prevent those objects from being deallocated, so it's generally recommended not to do so.
  190. .. rst-class:: classref-item-separator
  191. ----
  192. .. _class_Engine_method_get_architecture_name:
  193. .. rst-class:: classref-method
  194. :ref:`String<class_String>` **get_architecture_name**\ (\ ) |const| :ref:`๐Ÿ”—<class_Engine_method_get_architecture_name>`
  195. 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"``.
  196. To detect whether the current build is 64-bit, or the type of architecture, don't use the architecture name. Instead, use :ref:`OS.has_feature()<class_OS_method_has_feature>` to check for the ``"64"`` feature tag, or tags such as ``"x86"`` or ``"arm"``. See the :doc:`Feature Tags <../tutorials/export/feature_tags>` documentation for more details.
  197. \ **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 an ``x86_32`` Godot binary on an ``x86_64`` system, the returned value will still be ``"x86_32"``.
  198. .. rst-class:: classref-item-separator
  199. ----
  200. .. _class_Engine_method_get_author_info:
  201. .. rst-class:: classref-method
  202. :ref:`Dictionary<class_Dictionary>` **get_author_info**\ (\ ) |const| :ref:`๐Ÿ”—<class_Engine_method_get_author_info>`
  203. 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``.
  204. .. rst-class:: classref-item-separator
  205. ----
  206. .. _class_Engine_method_get_copyright_info:
  207. .. rst-class:: classref-method
  208. :ref:`Array<class_Array>`\[:ref:`Dictionary<class_Dictionary>`\] **get_copyright_info**\ (\ ) |const| :ref:`๐Ÿ”—<class_Engine_method_get_copyright_info>`
  209. Returns an :ref:`Array<class_Array>` of dictionaries with copyright information for every component of Godot's source code.
  210. 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:
  211. - ``files`` - :ref:`Array<class_Array>` of file paths from the source code affected by this component;
  212. - ``copyright`` - :ref:`Array<class_Array>` of owners of this component;
  213. - ``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/>`__").
  214. .. rst-class:: classref-item-separator
  215. ----
  216. .. _class_Engine_method_get_donor_info:
  217. .. rst-class:: classref-method
  218. :ref:`Dictionary<class_Dictionary>` **get_donor_info**\ (\ ) |const| :ref:`๐Ÿ”—<class_Engine_method_get_donor_info>`
  219. Returns a :ref:`Dictionary<class_Dictionary>` of categorized donor names. Each entry is an :ref:`Array<class_Array>` of strings:
  220. {``platinum_sponsors``, ``gold_sponsors``, ``silver_sponsors``, ``bronze_sponsors``, ``mini_sponsors``, ``gold_donors``, ``silver_donors``, ``bronze_donors``}
  221. .. rst-class:: classref-item-separator
  222. ----
  223. .. _class_Engine_method_get_frames_drawn:
  224. .. rst-class:: classref-method
  225. :ref:`int<class_int>` **get_frames_drawn**\ (\ ) :ref:`๐Ÿ”—<class_Engine_method_get_frames_drawn>`
  226. Returns the total number of frames drawn since the engine started.
  227. \ **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>`.
  228. .. rst-class:: classref-item-separator
  229. ----
  230. .. _class_Engine_method_get_frames_per_second:
  231. .. rst-class:: classref-method
  232. :ref:`float<class_float>` **get_frames_per_second**\ (\ ) |const| :ref:`๐Ÿ”—<class_Engine_method_get_frames_per_second>`
  233. Returns the average frames rendered every second (FPS), also known as the framerate.
  234. .. rst-class:: classref-item-separator
  235. ----
  236. .. _class_Engine_method_get_license_info:
  237. .. rst-class:: classref-method
  238. :ref:`Dictionary<class_Dictionary>` **get_license_info**\ (\ ) |const| :ref:`๐Ÿ”—<class_Engine_method_get_license_info>`
  239. 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.
  240. .. rst-class:: classref-item-separator
  241. ----
  242. .. _class_Engine_method_get_license_text:
  243. .. rst-class:: classref-method
  244. :ref:`String<class_String>` **get_license_text**\ (\ ) |const| :ref:`๐Ÿ”—<class_Engine_method_get_license_text>`
  245. Returns the full Godot license text.
  246. .. rst-class:: classref-item-separator
  247. ----
  248. .. _class_Engine_method_get_main_loop:
  249. .. rst-class:: classref-method
  250. :ref:`MainLoop<class_MainLoop>` **get_main_loop**\ (\ ) |const| :ref:`๐Ÿ”—<class_Engine_method_get_main_loop>`
  251. 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>`.
  252. \ **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>`.
  253. .. rst-class:: classref-item-separator
  254. ----
  255. .. _class_Engine_method_get_physics_frames:
  256. .. rst-class:: classref-method
  257. :ref:`int<class_int>` **get_physics_frames**\ (\ ) |const| :ref:`๐Ÿ”—<class_Engine_method_get_physics_frames>`
  258. 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>`.
  259. This method can be used to run expensive logic less often without relying on a :ref:`Timer<class_Timer>`:
  260. .. tabs::
  261. .. code-tab:: gdscript
  262. func _physics_process(_delta):
  263. if Engine.get_physics_frames() % 2 == 0:
  264. pass # Run expensive logic only once every 2 physics frames here.
  265. .. code-tab:: csharp
  266. public override void _PhysicsProcess(double delta)
  267. {
  268. base._PhysicsProcess(delta);
  269. if (Engine.GetPhysicsFrames() % 2 == 0)
  270. {
  271. // Run expensive logic only once every 2 physics frames here.
  272. }
  273. }
  274. .. rst-class:: classref-item-separator
  275. ----
  276. .. _class_Engine_method_get_physics_interpolation_fraction:
  277. .. rst-class:: classref-method
  278. :ref:`float<class_float>` **get_physics_interpolation_fraction**\ (\ ) |const| :ref:`๐Ÿ”—<class_Engine_method_get_physics_interpolation_fraction>`
  279. 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.
  280. .. rst-class:: classref-item-separator
  281. ----
  282. .. _class_Engine_method_get_process_frames:
  283. .. rst-class:: classref-method
  284. :ref:`int<class_int>` **get_process_frames**\ (\ ) |const| :ref:`๐Ÿ”—<class_Engine_method_get_process_frames>`
  285. 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>`.
  286. This method can be used to run expensive logic less often without relying on a :ref:`Timer<class_Timer>`:
  287. .. tabs::
  288. .. code-tab:: gdscript
  289. func _process(_delta):
  290. if Engine.get_process_frames() % 5 == 0:
  291. pass # Run expensive logic only once every 5 process (render) frames here.
  292. .. code-tab:: csharp
  293. public override void _Process(double delta)
  294. {
  295. base._Process(delta);
  296. if (Engine.GetProcessFrames() % 5 == 0)
  297. {
  298. // Run expensive logic only once every 5 process (render) frames here.
  299. }
  300. }
  301. .. rst-class:: classref-item-separator
  302. ----
  303. .. _class_Engine_method_get_script_language:
  304. .. rst-class:: classref-method
  305. :ref:`ScriptLanguage<class_ScriptLanguage>` **get_script_language**\ (\ index\: :ref:`int<class_int>`\ ) |const| :ref:`๐Ÿ”—<class_Engine_method_get_script_language>`
  306. Returns an instance of a :ref:`ScriptLanguage<class_ScriptLanguage>` with the given ``index``.
  307. .. rst-class:: classref-item-separator
  308. ----
  309. .. _class_Engine_method_get_script_language_count:
  310. .. rst-class:: classref-method
  311. :ref:`int<class_int>` **get_script_language_count**\ (\ ) :ref:`๐Ÿ”—<class_Engine_method_get_script_language_count>`
  312. Returns the number of available script languages. Use with :ref:`get_script_language()<class_Engine_method_get_script_language>`.
  313. .. rst-class:: classref-item-separator
  314. ----
  315. .. _class_Engine_method_get_singleton:
  316. .. rst-class:: classref-method
  317. :ref:`Object<class_Object>` **get_singleton**\ (\ name\: :ref:`StringName<class_StringName>`\ ) |const| :ref:`๐Ÿ”—<class_Engine_method_get_singleton>`
  318. 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>`.
  319. \ **Note:** Global singletons are not the same as autoloaded nodes, which are configurable in the project settings.
  320. .. rst-class:: classref-item-separator
  321. ----
  322. .. _class_Engine_method_get_singleton_list:
  323. .. rst-class:: classref-method
  324. :ref:`PackedStringArray<class_PackedStringArray>` **get_singleton_list**\ (\ ) |const| :ref:`๐Ÿ”—<class_Engine_method_get_singleton_list>`
  325. Returns a list of names of all available global singletons. See also :ref:`get_singleton()<class_Engine_method_get_singleton>`.
  326. .. rst-class:: classref-item-separator
  327. ----
  328. .. _class_Engine_method_get_version_info:
  329. .. rst-class:: classref-method
  330. :ref:`Dictionary<class_Dictionary>` **get_version_info**\ (\ ) |const| :ref:`๐Ÿ”—<class_Engine_method_get_version_info>`
  331. Returns the current engine version information as a :ref:`Dictionary<class_Dictionary>` containing the following entries:
  332. - ``major`` - Major version number as an int;
  333. - ``minor`` - Minor version number as an int;
  334. - ``patch`` - Patch version number as an int;
  335. - ``hex`` - Full version encoded as a hexadecimal int with one byte (2 hex digits) per number (see example below);
  336. - ``status`` - Status (such as "beta", "rc1", "rc2", "stable", etc.) as a String;
  337. - ``build`` - Build name (e.g. "custom_build") as a String;
  338. - ``hash`` - Full Git commit hash as a String;
  339. - ``timestamp`` - Holds the Git commit date UNIX timestamp in seconds as an int, or ``0`` if unavailable;
  340. - ``string`` - ``major``, ``minor``, ``patch``, ``status``, and ``build`` in a single String.
  341. 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``.
  342. \ **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:
  343. .. tabs::
  344. .. code-tab:: gdscript
  345. if Engine.get_version_info().hex >= 0x040100:
  346. pass # Do things specific to version 4.1 or later.
  347. else:
  348. pass # Do things specific to versions before 4.1.
  349. .. code-tab:: csharp
  350. if ((int)Engine.GetVersionInfo()["hex"] >= 0x040100)
  351. {
  352. // Do things specific to version 4.1 or later.
  353. }
  354. else
  355. {
  356. // Do things specific to versions before 4.1.
  357. }
  358. .. rst-class:: classref-item-separator
  359. ----
  360. .. _class_Engine_method_get_write_movie_path:
  361. .. rst-class:: classref-method
  362. :ref:`String<class_String>` **get_write_movie_path**\ (\ ) |const| :ref:`๐Ÿ”—<class_Engine_method_get_write_movie_path>`
  363. 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>`.
  364. .. rst-class:: classref-item-separator
  365. ----
  366. .. _class_Engine_method_has_singleton:
  367. .. rst-class:: classref-method
  368. :ref:`bool<class_bool>` **has_singleton**\ (\ name\: :ref:`StringName<class_StringName>`\ ) |const| :ref:`๐Ÿ”—<class_Engine_method_has_singleton>`
  369. Returns ``true`` if a singleton with the given ``name`` exists in the global scope. See also :ref:`get_singleton()<class_Engine_method_get_singleton>`.
  370. .. tabs::
  371. .. code-tab:: gdscript
  372. print(Engine.has_singleton("OS")) # Prints true
  373. print(Engine.has_singleton("Engine")) # Prints true
  374. print(Engine.has_singleton("AudioServer")) # Prints true
  375. print(Engine.has_singleton("Unknown")) # Prints false
  376. .. code-tab:: csharp
  377. GD.Print(Engine.HasSingleton("OS")); // Prints True
  378. GD.Print(Engine.HasSingleton("Engine")); // Prints True
  379. GD.Print(Engine.HasSingleton("AudioServer")); // Prints True
  380. GD.Print(Engine.HasSingleton("Unknown")); // Prints False
  381. \ **Note:** Global singletons are not the same as autoloaded nodes, which are configurable in the project settings.
  382. .. rst-class:: classref-item-separator
  383. ----
  384. .. _class_Engine_method_is_editor_hint:
  385. .. rst-class:: classref-method
  386. :ref:`bool<class_bool>` **is_editor_hint**\ (\ ) |const| :ref:`๐Ÿ”—<class_Engine_method_is_editor_hint>`
  387. 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:
  388. .. tabs::
  389. .. code-tab:: gdscript
  390. if Engine.is_editor_hint():
  391. draw_gizmos()
  392. else:
  393. simulate_physics()
  394. .. code-tab:: csharp
  395. if (Engine.IsEditorHint())
  396. DrawGizmos();
  397. else
  398. SimulatePhysics();
  399. See :doc:`Running code in the editor <../tutorials/plugins/running_code_in_the_editor>` in the documentation for more information.
  400. \ **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.
  401. .. rst-class:: classref-item-separator
  402. ----
  403. .. _class_Engine_method_is_embedded_in_editor:
  404. .. rst-class:: classref-method
  405. :ref:`bool<class_bool>` **is_embedded_in_editor**\ (\ ) |const| :ref:`๐Ÿ”—<class_Engine_method_is_embedded_in_editor>`
  406. 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.
  407. .. rst-class:: classref-item-separator
  408. ----
  409. .. _class_Engine_method_is_in_physics_frame:
  410. .. rst-class:: classref-method
  411. :ref:`bool<class_bool>` **is_in_physics_frame**\ (\ ) |const| :ref:`๐Ÿ”—<class_Engine_method_is_in_physics_frame>`
  412. Returns ``true`` if the engine is inside the fixed physics process step of the main loop.
  413. ::
  414. func _enter_tree():
  415. # Depending on when the node is added to the tree,
  416. # prints either "true" or "false".
  417. print(Engine.is_in_physics_frame())
  418. func _process(delta):
  419. print(Engine.is_in_physics_frame()) # Prints false
  420. func _physics_process(delta):
  421. print(Engine.is_in_physics_frame()) # Prints true
  422. .. rst-class:: classref-item-separator
  423. ----
  424. .. _class_Engine_method_register_script_language:
  425. .. rst-class:: classref-method
  426. :ref:`Error<enum_@GlobalScope_Error>` **register_script_language**\ (\ language\: :ref:`ScriptLanguage<class_ScriptLanguage>`\ ) :ref:`๐Ÿ”—<class_Engine_method_register_script_language>`
  427. Registers a :ref:`ScriptLanguage<class_ScriptLanguage>` instance to be available with ``ScriptServer``.
  428. Returns:
  429. - :ref:`@GlobalScope.OK<class_@GlobalScope_constant_OK>` on success;
  430. - :ref:`@GlobalScope.ERR_UNAVAILABLE<class_@GlobalScope_constant_ERR_UNAVAILABLE>` if ``ScriptServer`` has reached the limit and cannot register any new language;
  431. - :ref:`@GlobalScope.ERR_ALREADY_EXISTS<class_@GlobalScope_constant_ERR_ALREADY_EXISTS>` if ``ScriptServer`` already contains a language with similar extension/name/type.
  432. .. rst-class:: classref-item-separator
  433. ----
  434. .. _class_Engine_method_register_singleton:
  435. .. rst-class:: classref-method
  436. |void| **register_singleton**\ (\ name\: :ref:`StringName<class_StringName>`, instance\: :ref:`Object<class_Object>`\ ) :ref:`๐Ÿ”—<class_Engine_method_register_singleton>`
  437. Registers the given :ref:`Object<class_Object>` ``instance`` as a singleton, available globally under ``name``. Useful for plugins.
  438. .. rst-class:: classref-item-separator
  439. ----
  440. .. _class_Engine_method_unregister_script_language:
  441. .. rst-class:: classref-method
  442. :ref:`Error<enum_@GlobalScope_Error>` **unregister_script_language**\ (\ language\: :ref:`ScriptLanguage<class_ScriptLanguage>`\ ) :ref:`๐Ÿ”—<class_Engine_method_unregister_script_language>`
  443. Unregisters the :ref:`ScriptLanguage<class_ScriptLanguage>` instance from ``ScriptServer``.
  444. Returns:
  445. - :ref:`@GlobalScope.OK<class_@GlobalScope_constant_OK>` on success;
  446. - :ref:`@GlobalScope.ERR_DOES_NOT_EXIST<class_@GlobalScope_constant_ERR_DOES_NOT_EXIST>` if the language is not registered in ``ScriptServer``.
  447. .. rst-class:: classref-item-separator
  448. ----
  449. .. _class_Engine_method_unregister_singleton:
  450. .. rst-class:: classref-method
  451. |void| **unregister_singleton**\ (\ name\: :ref:`StringName<class_StringName>`\ ) :ref:`๐Ÿ”—<class_Engine_method_unregister_singleton>`
  452. 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>`.
  453. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  454. .. |required| replace:: :abbr:`required (This method is required to be overridden when extending its base class.)`
  455. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  456. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  457. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  458. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  459. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`
  460. .. |bitfield| replace:: :abbr:`BitField (This value is an integer composed as a bitmask of the following flags.)`
  461. .. |void| replace:: :abbr:`void (No return value.)`