upgrading_to_godot_4.1.rst 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295
  1. .. _doc_upgrading_to_godot_4.1:
  2. Upgrading from Godot 4.0 to Godot 4.1
  3. =====================================
  4. For most games and apps made with 4.0, it should be relatively safe to migrate to 4.1.
  5. This page intends to cover everything you need to pay attention to when migrating
  6. your project.
  7. Breaking changes
  8. ----------------
  9. If you are migrating from 4.0 to 4.1, the breaking changes listed here might
  10. affect you. Changes are grouped by areas/systems.
  11. .. warning::
  12. The GDExtension API completely breaks compatibility in 4.1, so it's not included
  13. in the table below. See the :ref:`updating_your_gdextension_for_godot_4_1` section
  14. for more information.
  15. This article indicates whether each breaking change affects GDScript and whether
  16. the C# breaking change is *binary compatible* or *source compatible*:
  17. - **Binary compatible** - Existing binaries will load and execute successfully without
  18. recompilation, and the runtime behavior won't change.
  19. - **Source compatible** - Source code will compile successfully without changes when
  20. upgrading Godot.
  21. Core
  22. ^^^^
  23. ======================================================================================================================== =================== ==================== ==================== ===========
  24. Change GDScript Compatible C# Binary Compatible C# Source Compatible Introduced
  25. ======================================================================================================================== =================== ==================== ==================== ===========
  26. **Basis**
  27. Method ``looking_at`` adds a new ``use_model_front`` optional parameter |✔️| |✔️| |✔️| `GH-76082`_
  28. **Object**
  29. Method ``get_meta_list`` changes return type from ``PackedStringArray`` to ``Array[StringName]`` |✔️| |❌| |❌| `GH-76418`_
  30. **Transform3D**
  31. Method ``looking_at`` adds a new ``use_model_front`` optional parameter |✔️| |✔️| |✔️| `GH-76082`_
  32. **UndoRedo**
  33. Method ``create_action`` adds a new ``backward_undo_ops`` optional parameter |✔️| |✔️ with compat| |✔️| `GH-76688`_
  34. **WorkerThreadPool**
  35. Method ``wait_for_task_completion`` changes return type from ``void`` to ``Error`` |✔️| |❌| |✔️| `GH-77143`_
  36. ======================================================================================================================== =================== ==================== ==================== ===========
  37. Animation
  38. ^^^^^^^^^
  39. ======================================================================================================================== =================== ==================== ==================== ===========
  40. Change GDScript Compatible C# Binary Compatible C# Source Compatible Introduced
  41. ======================================================================================================================== =================== ==================== ==================== ===========
  42. **AnimationNode**
  43. Method ``_process`` adds a new ``test_only`` parameter |❌| |❌| |❌| `GH-75759`_
  44. Method ``blend_input`` adds a new ``test_only`` optional parameter |✔️| |✔️ with compat| |✔️| `GH-75759`_
  45. Method ``blend_node`` adds a new ``test_only`` optional parameter |✔️| |✔️ with compat| |✔️| `GH-75759`_
  46. **AnimationNodeStateMachinePlayback**
  47. Method ``get_travel_path`` changes return type from ``PackedStringArray`` to ``Array[StringName]`` |✔️| |❌| |❌| `GH-76418`_
  48. ======================================================================================================================== =================== ==================== ==================== ===========
  49. 2D nodes
  50. ^^^^^^^^
  51. ======================================================================================================================== =================== ==================== ==================== ===========
  52. Change GDScript Compatible C# Binary Compatible C# Source Compatible Introduced
  53. ======================================================================================================================== =================== ==================== ==================== ===========
  54. **PathFollow2D**
  55. Property ``lookahead`` removed |❌| |❌| |❌| `GH-72842`_
  56. ======================================================================================================================== =================== ==================== ==================== ===========
  57. 3D nodes
  58. ^^^^^^^^
  59. ======================================================================================================================== =================== ==================== ==================== ===========
  60. Change GDScript Compatible C# Binary Compatible C# Source Compatible Introduced
  61. ======================================================================================================================== =================== ==================== ==================== ===========
  62. **Geometry3D**
  63. Method ``segment_intersects_convex`` changes ``planes`` parameter type from untyped ``Array`` to ``Array[Plane]`` |✔️| |✔️ with compat| |❌| `GH-76418`_
  64. **MeshInstance3D**
  65. Method ``create_multiple_convex_collisions`` adds a new ``settings`` optional parameter |✔️| |✔️ with compat| |✔️| `GH-72152`_
  66. **Node3D**
  67. Method ``look_at`` adds a new ``use_model_front`` optional parameter |✔️| |✔️ with compat| |✔️| `GH-76082`_
  68. Method ``look_at_from_position`` adds a new ``use_model_front`` optional parameter |✔️| |✔️ with compat| |✔️| `GH-76082`_
  69. ======================================================================================================================== =================== ==================== ==================== ===========
  70. GUI nodes
  71. ^^^^^^^^^
  72. ======================================================================================================================== =================== ==================== ==================== ===========
  73. Change GDScript Compatible C# Binary Compatible C# Source Compatible Introduced
  74. ======================================================================================================================== =================== ==================== ==================== ===========
  75. **CodeEdit**
  76. Method ``add_code_completion_option`` adds a new ``location`` optional parameter |✔️| |✔️ with compat| |✔️| `GH-75746`_
  77. **RichTextLabel**
  78. Method ``push_list`` adds a new ``bullet`` optional parameter |✔️| |✔️ with compat| |✔️| `GH-75017`_
  79. Method ``push_paragraph`` adds a new ``justification_flags`` optional parameter |✔️| |✔️ with compat| |✔️| `GH-75250`_
  80. Method ``push_paragraph`` adds a new ``tab_stops`` optional parameter |✔️| |✔️ with compat| |✔️| `GH-76401`_
  81. **Tree**
  82. Method ``edit_selected`` adds a new ``force_edit`` optional parameter |✔️| |✔️ with compat| |✔️| `GH-76794`_
  83. ======================================================================================================================== =================== ==================== ==================== ===========
  84. Physics
  85. ^^^^^^^
  86. ======================================================================================================================== =================== ==================== ==================== ===========
  87. Change GDScript Compatible C# Binary Compatible C# Source Compatible Introduced
  88. ======================================================================================================================== =================== ==================== ==================== ===========
  89. **Area2D**
  90. Property ``priority`` changes type from ``float`` to ``int`` |❌| |❌| |❌| `GH-72749`_
  91. **Area3D**
  92. Property ``priority`` changes type from ``float`` to ``int`` |❌| |❌| |❌| `GH-72749`_
  93. **PhysicsDirectSpaceState2D**
  94. Method ``collide_shape`` changes return type from ``Array[PackedVector2Array]`` to ``Array[Vector2]`` |❌| |❌| |❌| `GH-75260`_
  95. **PhysicsDirectSpaceState3D**
  96. Method ``collide_shape`` changes return type from ``Array[PackedVector3Array]`` to ``Array[Vector3]`` |❌| |❌| |❌| `GH-75260`_
  97. ======================================================================================================================== =================== ==================== ==================== ===========
  98. Rendering
  99. ^^^^^^^^^
  100. ======================================================================================================================== =================== ==================== ==================== ===========
  101. Change GDScript Compatible C# Binary Compatible C# Source Compatible Introduced
  102. ======================================================================================================================== =================== ==================== ==================== ===========
  103. **RDShaderFile**
  104. Method ``get_version_list`` changes return type from ``PackedStringArray`` to ``Array[StringName]`` |✔️| |❌| |❌| `GH-76418`_
  105. **RenderingDevice**
  106. Method ``draw_list_begin`` changes ``storage_textures`` parameter type from untyped ``Array`` to ``Array[RID]`` |✔️| |✔️ with compat| |❌| `GH-76418`_
  107. **RenderingServer**
  108. Method ``global_shader_parameter_get_list`` changes return type from ``PackedStringArray`` to ``Array[StringName]`` |✔️| |❌| |❌| `GH-76418`_
  109. **SurfaceTool**
  110. Method ``add_triangle_fan`` changes ``tangents`` parameter type from untyped ``Array`` to ``Array[Plane]`` |✔️| |✔️ with compat| |❌| `GH-76418`_
  111. ======================================================================================================================== =================== ==================== ==================== ===========
  112. Navigation
  113. ^^^^^^^^^^
  114. ======================================================================================================================== =================== ==================== ==================== ===========
  115. Change GDScript Compatible C# Binary Compatible C# Source Compatible Introduced
  116. ======================================================================================================================== =================== ==================== ==================== ===========
  117. **NavigationAgent2D**
  118. Method ``set_velocity`` replaced with ``velocity`` property |✔️| |❌| |❌| `GH-69988`_
  119. Property ``time_horizon`` split into ``time_horizon_agents`` and ``time_horizon_obstacles`` |❌| |❌| |❌| `GH-69988`_
  120. **NavigationAgent3D**
  121. Property ``agent_height_offset`` renamed to ``path_height_offset`` |❌| |❌| |❌| `GH-69988`_
  122. Property ``ignore_y`` removed |❌| |❌| |❌| `GH-69988`_
  123. Method ``set_velocity`` replaced with ``velocity`` property |✔️| |❌| |❌| `GH-69988`_
  124. Property ``time_horizon`` split into ``time_horizon_agents`` and ``time_horizon_obstacles`` |❌| |❌| |❌| `GH-69988`_
  125. **NavigationObstacle2D**
  126. Property ``estimate_radius`` removed |❌| |❌| |❌| `GH-69988`_
  127. Method ``get_rid`` renamed to ``get_agent_rid`` |❌| |❌| |❌| `GH-69988`_
  128. **NavigationObstacle3D**
  129. Property ``estimate_radius`` removed |❌| |❌| |❌| `GH-69988`_
  130. Method ``get_rid`` renamed to ``get_agent_rid`` |❌| |❌| |❌| `GH-69988`_
  131. **NavigationServer2D**
  132. Method ``agent_set_callback`` renamed to ``agent_set_avoidance_callback`` |❌| |❌| |❌| `GH-69988`_
  133. Method ``agent_set_target_velocity`` removed |❌| |❌| |❌| `GH-69988`_
  134. Method ``agent_set_time_horizon`` split into ``agent_set_time_horizon_agents`` and ``agent_set_time_horizon_obstacles`` |❌| |❌| |❌| `GH-69988`_
  135. **NavigationServer3D**
  136. Method ``agent_set_callback`` renamed to ``agent_set_avoidance_callback`` |❌| |❌| |❌| `GH-69988`_
  137. Method ``agent_set_target_velocity`` removed |❌| |❌| |❌| `GH-69988`_
  138. Method ``agent_set_time_horizon`` split into ``agent_set_time_horizon_agents`` and ``agent_set_time_horizon_obstacles`` |❌| |❌| |❌| `GH-69988`_
  139. ======================================================================================================================== =================== ==================== ==================== ===========
  140. Networking
  141. ^^^^^^^^^^
  142. ======================================================================================================================== =================== ==================== ==================== ===========
  143. Change GDScript Compatible C# Binary Compatible C# Source Compatible Introduced
  144. ======================================================================================================================== =================== ==================== ==================== ===========
  145. **WebRTCPeerConnectionExtension**
  146. Method ``_create_data_channel`` changes return type from ``Object`` to ``WebRTCDataChannel`` |✔️| |❌| |✔️| `GH-78237`_
  147. ======================================================================================================================== =================== ==================== ==================== ===========
  148. Editor plugins
  149. ^^^^^^^^^^^^^^
  150. ======================================================================================================================== =================== ==================== ==================== ===========
  151. Change GDScript Compatible C# Binary Compatible C# Source Compatible Introduced
  152. ======================================================================================================================== =================== ==================== ==================== ===========
  153. **AnimationTrackEditPlugin**
  154. Type ``AnimationTrackEditPlugin`` removed |❌| |❌| |❌| `GH-76413`_
  155. **EditorInterface**
  156. Type ``EditorInterface`` changes inheritance from ``Node`` to ``Object`` |✔️| |❌| |❌| `GH-76176`_
  157. Method ``set_movie_maker_enabled`` replaced with ``movie_maker_enabled`` property |✔️| |❌| |❌| `GH-76176`_
  158. Method ``is_movie_maker_enabled`` replaced with ``movie_maker_enabled`` property |✔️| |❌| |❌| `GH-76176`_
  159. **EditorResourcePreviewGenerator**
  160. Method ``_generate`` adds a new ``metadata`` parameter |❌| |❌| |❌| `GH-64628`_
  161. Method ``_generate_from_path`` adds a new ``metadata`` parameter |❌| |❌| |❌| `GH-64628`_
  162. **EditorUndoRedoManager**
  163. Method ``create_action`` adds a new ``backward_undo_ops`` optional parameter |✔️| |✔️ with compat| |✔️| `GH-76688`_
  164. ======================================================================================================================== =================== ==================== ==================== ===========
  165. Behavior changes
  166. ----------------
  167. In 4.1 some behavior changes have been introduced, which might require you to adjust your project.
  168. ================================================================================================================================================================================================== ===========
  169. Change Introduced
  170. ================================================================================================================================================================================================== ===========
  171. **SubViewportContainer**
  172. When input events should reach SubViewports and their children, ``SubViewportContainer.mouse_filter`` now needs to be ``MOUSE_FILTER_STOP`` or ``MOUSE_FILTER_PASS``. See `GH-79271`_ for details. `GH-57894`_
  173. Multiple layered ``SubViewportContainer`` nodes, that should all receive mouse input events, now need to be replaced by ``Area2D`` nodes. See `GH-79128`_ for details. `GH-57894`_
  174. **Viewport**
  175. ``Viewport`` nodes, that have Physics Picking enabled, now automatically set InputEvents as handled. See `GH-79897`_ for workarounds. `GH-77595`_
  176. ================================================================================================================================================================================================== ===========
  177. .. |❌| replace:: :abbr:`❌ (This API breaks compatibility.)`
  178. .. |✔️| replace:: :abbr:`✔️ (This API does not break compatibility.)`
  179. .. |✔️ with compat| replace:: :abbr:`✔️ (This API does not break compatibility. A compatibility method was added.)`
  180. .. _GH-57894: https://github.com/godotengine/godot/pull/57894
  181. .. _GH-64628: https://github.com/godotengine/godot/pull/64628
  182. .. _GH-69988: https://github.com/godotengine/godot/pull/69988
  183. .. _GH-72152: https://github.com/godotengine/godot/pull/72152
  184. .. _GH-72749: https://github.com/godotengine/godot/pull/72749
  185. .. _GH-72842: https://github.com/godotengine/godot/pull/72842
  186. .. _GH-75017: https://github.com/godotengine/godot/pull/75017
  187. .. _GH-75250: https://github.com/godotengine/godot/pull/75250
  188. .. _GH-75260: https://github.com/godotengine/godot/pull/75260
  189. .. _GH-75746: https://github.com/godotengine/godot/pull/75746
  190. .. _GH-75759: https://github.com/godotengine/godot/pull/75759
  191. .. _GH-76082: https://github.com/godotengine/godot/pull/76082
  192. .. _GH-76176: https://github.com/godotengine/godot/pull/76176
  193. .. _GH-76401: https://github.com/godotengine/godot/pull/76401
  194. .. _GH-76413: https://github.com/godotengine/godot/pull/76413
  195. .. _GH-76418: https://github.com/godotengine/godot/pull/76418
  196. .. _GH-76688: https://github.com/godotengine/godot/pull/76688
  197. .. _GH-76794: https://github.com/godotengine/godot/pull/76794
  198. .. _GH-77143: https://github.com/godotengine/godot/pull/77143
  199. .. _GH-77595: https://github.com/godotengine/godot/pull/77595
  200. .. _GH-78237: https://github.com/godotengine/godot/pull/78237
  201. .. _GH-79128: https://github.com/godotengine/godot/issues/79128
  202. .. _GH-79271: https://github.com/godotengine/godot/issues/79271
  203. .. _GH-79897: https://github.com/godotengine/godot/issues/79897
  204. .. _updating_your_gdextension_for_godot_4_1:
  205. Updating your GDExtension for 4.1
  206. ---------------------------------
  207. GDExtension is still in beta. Until it's marked as stable, compatibility may break when
  208. upgrading to a new minor version of Godot.
  209. In order to fix a serious bug, in Godot 4.1 we had to break binary compatibility in a big
  210. way and source compatibility in a small way.
  211. This means that GDExtensions made for Godot 4.0 will need to be recompiled for Godot 4.1
  212. (using the ``4.1`` branch of godot-cpp), with a small change to their source code.
  213. In Godot 4.0, your "entry_symbol" function looks something like this:
  214. .. code-block:: cpp
  215. GDExtensionBool GDE_EXPORT example_library_init(const GDExtensionInterface *p_interface, const GDExtensionClassLibraryPtr p_library, GDExtensionInitialization *r_initialization) {
  216. godot::GDExtensionBinding::InitObject init_obj(p_interface, p_library, r_initialization);
  217. init_obj.register_initializer(initialize_example_module);
  218. init_obj.register_terminator(uninitialize_example_module);
  219. init_obj.set_minimum_library_initialization_level(MODULE_INITIALIZATION_LEVEL_SCENE);
  220. return init_obj.init();
  221. }
  222. However, for Godot 4.1, it should look like:
  223. .. code-block:: cpp
  224. GDExtensionBool GDE_EXPORT example_library_init(GDExtensionInterfaceGetProcAddress p_get_proc_address, const GDExtensionClassLibraryPtr p_library, GDExtensionInitialization *r_initialization) {
  225. godot::GDExtensionBinding::InitObject init_obj(p_get_proc_address, p_library, r_initialization);
  226. init_obj.register_initializer(initialize_example_module);
  227. init_obj.register_terminator(uninitialize_example_module);
  228. init_obj.set_minimum_library_initialization_level(MODULE_INITIALIZATION_LEVEL_SCENE);
  229. return init_obj.init();
  230. }
  231. There are two small changes:
  232. #. The first argument changes from ``const GDExtensionInterface *p_interface`` to ``GDExtensionInterfaceGetProcAddress p_get_proc_address``
  233. #. The constructor for the `init_obj` variable now receives ``p_get_proc_address`` as its first parameter
  234. You also need to add an extra ``compatibility_minimum`` line to your ``.gdextension`` file, so that it looks something like::
  235. [configuration]
  236. entry_symbol = "example_library_init"
  237. compatibility_minimum = 4.1
  238. This lets Godot know that your GDExtension has been updated and is safe to load in Godot 4.1.