upgrading_to_godot_4.rst 42 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673
  1. .. _doc_upgrading_to_godot_4:
  2. Upgrading from Godot 3 to Godot 4
  3. =================================
  4. Should I upgrade to Godot 4?
  5. ----------------------------
  6. Before beginning the upgrade process, it's worth thinking about the advantages
  7. and disadvantages that upgrading would bring to your project.
  8. Advantages of upgrading
  9. ^^^^^^^^^^^^^^^^^^^^^^^
  10. Along with the
  11. `new features present in 4.0 <https://github.com/godotengine/godot/blob/master/CHANGELOG.md>`__,
  12. upgrading gives the following advantages:
  13. - Many bugs are fixed in 4.0, but cannot be resolved in 3.x for various reasons
  14. (such as graphics API differences or backwards compatibility).
  15. - 4.x will enjoy a longer :ref:`support period <doc_release_policy>`. Godot 3.x
  16. will continue to be supported for some time after 4.0 is released, but it will
  17. eventually stop receiving support.
  18. See :ref:`doc_docs_changelog` for a list of pages documenting new features in Godot 4.0.
  19. Disadvantages of upgrading
  20. ^^^^^^^^^^^^^^^^^^^^^^^^^^
  21. If you don't *need* any features present in Godot 4.0, you may want to stay on
  22. Godot 3.x for the following reasons:
  23. - `Godot 3.x is tried and true, while Godot 4 remains in its early stages. <https://godotengine.org/article/release-management-4-0-and-beyond>`__
  24. - Godot 4.0 is expected to contain workflow and performance issues that Godot
  25. 3.x doesn't have. If stability is crucial to your project, it's recommended to
  26. wait for the first minor release in the 4.x series to land, along with its
  27. respective patch release. This means staying on Godot 3.x until Godot 4.1.1 is
  28. released.
  29. - Godot 4 has fewer third-party tutorials available compared to Godot 3.x.
  30. If you're new to game engines, you may have a better experience using Godot 3.x
  31. as a result.
  32. - Godot 4's baseline hardware requirements (such as memory usage) are slightly
  33. higher, both for the editor and exported projects. This was required for the
  34. implementation of some core optimizations.
  35. - Since Godot 4 includes more features than Godot 3, Godot 4's binary size for
  36. exported projects is larger. While this can be mitigated by
  37. :ref:`optimizing a build for size <doc_optimizing_for_size>`, a 4.0 build with
  38. a given set of enabled modules will remain larger compared to a 3.x build with
  39. the same modules. This can be an issue for
  40. :ref:`exporting to the Web <doc_exporting_for_web>`, as binary size directly
  41. influences how fast the engine can initialize (regardless of download speed).
  42. - Godot 4 does not and will not have support for GLES2 rendering.
  43. (There is still support for GLES3 rendering using the new OpenGL backend,
  44. which means that devices without Vulkan support can still run Godot 4.)
  45. - If you are targeting **very** old hardware such as Intel Sandy Bridge (2nd
  46. generation) integrated graphics, this will prevent the project from running
  47. on such hardware after upgrading.
  48. `Software OpenGL implementations <https://github.com/pal1000/mesa-dist-win>`__
  49. can be used to bypass this limitation, but they're too slow for gaming.
  50. Caveats of upgrading
  51. ^^^^^^^^^^^^^^^^^^^^
  52. **Since Godot 4 is a complete rewrite in many aspects, some features have
  53. unfortunately been lost in the process.** Some of these features may be restored
  54. in future Godot releases:
  55. - Bullet physics was removed in favor of GodotPhysics. This only affects 3D
  56. projects that used the default physics engine (which was Bullet) and didn't
  57. manually change it to GodotPhysics. There are no plans to re-add Bullet physics
  58. in core, but a third-party add-on could be created for it thanks to
  59. GDExtension.
  60. - Rendering in 2D is no longer performed in HDR, which means "overbright"
  61. modulate values have no visible effect. This is planned to be restored at some
  62. point in the future.
  63. - While rendering still happens in HDR in 3D when using the Forward Plus or
  64. Forward Mobile backends, Viewports cannot return HDR data anymore. This is
  65. planned to be restored at some point in the future.
  66. - Mono was replaced by .NET 6. This means exporting C# projects to Android, iOS
  67. and HTML5 is no longer supported for now. Exporting C# projects to desktop
  68. platforms is still supported. Support for exporting C# projects to more
  69. platforms will be restored in future 4.x releases as upstream support
  70. improves.
  71. You can find a more complete list of functional regressions by searching for
  72. `issues labeled "regression" but not "bug" on GitHub <https://github.com/godotengine/godot/issues?q=is%3Aissue+is%3Aopen+label%3Aregression+-label%3Abug>`__.
  73. Preparing before the upgrade (optional)
  74. ---------------------------------------
  75. If you want to be ready to upgrade to Godot 4 in the future, consider using
  76. :ref:`class_Tweener` and the :ref:`class_Time` singleton in your project. These
  77. classes are both available in Godot 3.5 and later.
  78. This way, you won't be relying on the deprecated Tween node and OS time
  79. functions, both of which are removed in Godot 4.0.
  80. It's also a good idea to rename external shaders so that their extension is
  81. ``.gdshader`` instead of ``.shader``. Godot 3.x supports both extensions, but
  82. only ``.gdshader`` is supported in Godot 4.0.
  83. Running the project upgrade tool
  84. --------------------------------
  85. .. warning::
  86. **Make a full backup of your project** before upgrading! The project upgrade
  87. tool will *not* perform any backups of the project that is being upgraded.
  88. You can backup a project by using version control, or by copying the project
  89. folder to another location.
  90. To use the project upgrade tool:
  91. 1. Open the Godot 4 project manager.
  92. 2. Import the Godot 3.x project using the **Import** button, or use the **Scan**
  93. button to find the project within a folder.
  94. 3. Double-click the imported project (or select the project then choose **Edit**).
  95. 4. You will see a dialog appearing with two options: **Convert project.godot
  96. Only** and **Convert Full Project**. After ensuring your project is backed up
  97. (see the above warning), choose **Convert Full Project**. **Convert
  98. project.godot Only** is intended to be used for advanced use cases *only*, in
  99. case the conversion tool fails.
  100. 5. Wait until the project conversion process finishes. This can take up to a few
  101. minutes for large projects with lots of scenes.
  102. 6. When the project manager interface becomes available again, double-click the
  103. project (or select the project then choose **Edit**) to open it in the
  104. editor.
  105. .. note::
  106. Only Godot 3.0 and later projects can be upgraded using the project
  107. conversion tool found in the Godot 4 editor.
  108. It's recommended to ensure that your project is up-to-date with the latest
  109. 3.x stable release before running the project upgrade tool.
  110. Fixing the project after running the project upgrade tool
  111. ---------------------------------------------------------
  112. After upgrading the project, you may notice that certain things don't look as
  113. they should. Scripts will likely contain various errors as well (possibly
  114. hundreds in large projects). This is because the project upgrade tool cannot
  115. cater to all situations. Therefore, a large part of the upgrade process remains
  116. manual.
  117. Automatically renamed nodes and resources
  118. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  119. The list below refers to nodes which were simply renamed for consistency or
  120. clarity in Godot 4.0. The project upgrade tool renames them automatically in
  121. your scripts.
  122. One noteworthy set of renames is 3D nodes, which all got a ``3D`` suffix added for
  123. consistency with their 2D counterparts. For example, ``Area`` is now ``Area3D``.
  124. For ease of searching, this table lists all nodes and resources that were renamed
  125. and are automatically converted, excluding the ones which only involved adding
  126. a ``3D`` suffix to the old name:
  127. +-----------------------------------------+-------------------------------------------+
  128. | Old name (Godot 3.x) | New name (Godot 4) |
  129. +=========================================+===========================================+
  130. | AnimatedSprite | AnimatedSprite2D |
  131. +-----------------------------------------+-------------------------------------------+
  132. | ARVRCamera | XRCamera3D |
  133. +-----------------------------------------+-------------------------------------------+
  134. | ARVRController | XRController3D |
  135. +-----------------------------------------+-------------------------------------------+
  136. | ARVRAnchor | XRAnchor3D |
  137. +-----------------------------------------+-------------------------------------------+
  138. | ARVRInterface | XRInterface |
  139. +-----------------------------------------+-------------------------------------------+
  140. | ARVROrigin | XROrigin3D |
  141. +-----------------------------------------+-------------------------------------------+
  142. | ARVRPositionalTracker | XRPositionalTracker |
  143. +-----------------------------------------+-------------------------------------------+
  144. | ARVRServer | XRServer |
  145. +-----------------------------------------+-------------------------------------------+
  146. | CubeMesh | BoxMesh |
  147. +-----------------------------------------+-------------------------------------------+
  148. | EditorSpatialGizmo | EditorNode3DGizmo |
  149. +-----------------------------------------+-------------------------------------------+
  150. | EditorSpatialGizmoPlugin | EditorNode3DGizmoPlugin |
  151. +-----------------------------------------+-------------------------------------------+
  152. | GIProbe | VoxelGI |
  153. +-----------------------------------------+-------------------------------------------+
  154. | GIProbeData | VoxelGIData |
  155. +-----------------------------------------+-------------------------------------------+
  156. | GradientTexture | GradientTexture1D |
  157. +-----------------------------------------+-------------------------------------------+
  158. | KinematicBody | CharacterBody3D |
  159. +-----------------------------------------+-------------------------------------------+
  160. | KinematicBody2D | CharacterBody2D |
  161. +-----------------------------------------+-------------------------------------------+
  162. | Light2D | PointLight2D |
  163. +-----------------------------------------+-------------------------------------------+
  164. | LineShape2D | WorldBoundaryShape2D |
  165. +-----------------------------------------+-------------------------------------------+
  166. | Listener | AudioListener3D |
  167. +-----------------------------------------+-------------------------------------------+
  168. | NavigationMeshInstance | NavigationRegion3D |
  169. +-----------------------------------------+-------------------------------------------+
  170. | NavigationPolygonInstance | NavigationRegion2D |
  171. +-----------------------------------------+-------------------------------------------+
  172. | Navigation2DServer | NavigationServer2D |
  173. +-----------------------------------------+-------------------------------------------+
  174. | PanoramaSky | Sky |
  175. +-----------------------------------------+-------------------------------------------+
  176. | Particles | GPUParticles3D |
  177. +-----------------------------------------+-------------------------------------------+
  178. | Particles2D | GPUParticles2D |
  179. +-----------------------------------------+-------------------------------------------+
  180. | ParticlesMaterial | ParticleProcessMaterial |
  181. +-----------------------------------------+-------------------------------------------+
  182. | Physics2DDirectBodyState | PhysicsDirectBodyState2D |
  183. +-----------------------------------------+-------------------------------------------+
  184. | Physics2DDirectSpaceState | PhysicsDirectSpaceState2D |
  185. +-----------------------------------------+-------------------------------------------+
  186. | Physics2DServer | PhysicsServer2D |
  187. +-----------------------------------------+-------------------------------------------+
  188. | Physics2DShapeQueryParameters | PhysicsShapeQueryParameters2D |
  189. +-----------------------------------------+-------------------------------------------+
  190. | Physics2DTestMotionResult | PhysicsTestMotionResult2D |
  191. +-----------------------------------------+-------------------------------------------+
  192. | PlaneShape | WorldBoundaryShape3D |
  193. +-----------------------------------------+-------------------------------------------+
  194. | Position2D | Marker2D |
  195. +-----------------------------------------+-------------------------------------------+
  196. | Position3D | Marker3D |
  197. +-----------------------------------------+-------------------------------------------+
  198. | ProceduralSky | Sky |
  199. +-----------------------------------------+-------------------------------------------+
  200. | RayShape | SeparationRayShape3D |
  201. +-----------------------------------------+-------------------------------------------+
  202. | RayShape2D | SeparationRayShape2D |
  203. +-----------------------------------------+-------------------------------------------+
  204. | ShortCut | Shortcut |
  205. +-----------------------------------------+-------------------------------------------+
  206. | Spatial | Node3D |
  207. +-----------------------------------------+-------------------------------------------+
  208. | SpatialGizmo | Node3DGizmo |
  209. +-----------------------------------------+-------------------------------------------+
  210. | SpatialMaterial | StandardMaterial3D |
  211. +-----------------------------------------+-------------------------------------------+
  212. | Sprite | Sprite2D |
  213. +-----------------------------------------+-------------------------------------------+
  214. | StreamTexture | CompressedTexture2D |
  215. +-----------------------------------------+-------------------------------------------+
  216. | TextureProgress | TextureProgressBar |
  217. +-----------------------------------------+-------------------------------------------+
  218. | VideoPlayer | VideoStreamPlayer |
  219. +-----------------------------------------+-------------------------------------------+
  220. | ViewportContainer | SubViewportContainer |
  221. +-----------------------------------------+-------------------------------------------+
  222. | Viewport | SubViewport |
  223. +-----------------------------------------+-------------------------------------------+
  224. | VisibilityEnabler | VisibleOnScreenEnabler3D |
  225. +-----------------------------------------+-------------------------------------------+
  226. | VisibilityNotifier | VisibleOnScreenNotifier3D |
  227. +-----------------------------------------+-------------------------------------------+
  228. | VisibilityNotifier2D | VisibleOnScreenNotifier2D |
  229. +-----------------------------------------+-------------------------------------------+
  230. | VisibilityNotifier3D | VisibleOnScreenNotifier3D |
  231. +-----------------------------------------+-------------------------------------------+
  232. | VisualServer | RenderingServer |
  233. +-----------------------------------------+-------------------------------------------+
  234. | VisualShaderNodeScalarConstant | VisualShaderNodeFloatConstant |
  235. +-----------------------------------------+-------------------------------------------+
  236. | VisualShaderNodeScalarFunc | VisualShaderNodeFloatFunc |
  237. +-----------------------------------------+-------------------------------------------+
  238. | VisualShaderNodeScalarOp | VisualShaderNodeFloatOp |
  239. +-----------------------------------------+-------------------------------------------+
  240. | VisualShaderNodeScalarClamp | VisualShaderNodeClamp |
  241. +-----------------------------------------+-------------------------------------------+
  242. | VisualShaderNodeVectorClamp | VisualShaderNodeClamp |
  243. +-----------------------------------------+-------------------------------------------+
  244. | VisualShaderNodeScalarInterp | VisualShaderNodeMix |
  245. +-----------------------------------------+-------------------------------------------+
  246. | VisualShaderNodeVectorInterp | VisualShaderNodeMix |
  247. +-----------------------------------------+-------------------------------------------+
  248. | VisualShaderNodeVectorScalarMix | VisualShaderNodeMix |
  249. +-----------------------------------------+-------------------------------------------+
  250. | VisualShaderNodeScalarSmoothStep | VisualShaderNodeSmoothStep |
  251. +-----------------------------------------+-------------------------------------------+
  252. | VisualShaderNodeVectorSmoothStep | VisualShaderNodeSmoothStep |
  253. +-----------------------------------------+-------------------------------------------+
  254. | VisualShaderNodeVectorScalarSmoothStep | VisualShaderNodeSmoothStep |
  255. +-----------------------------------------+-------------------------------------------+
  256. | VisualShaderNodeVectorScalarStep | VisualShaderNodeStep |
  257. +-----------------------------------------+-------------------------------------------+
  258. | VisualShaderNodeScalarSwitch | VisualShaderNodeSwitch |
  259. +-----------------------------------------+-------------------------------------------+
  260. | VisualShaderNodeScalarTransformMult | VisualShaderNodeTransformOp |
  261. +-----------------------------------------+-------------------------------------------+
  262. | VisualShaderNodeScalarDerivativeFunc | VisualShaderNodeDerivativeFunc |
  263. +-----------------------------------------+-------------------------------------------+
  264. | VisualShaderNodeVectorDerivativeFunc | VisualShaderNodeDerivativeFunc |
  265. +-----------------------------------------+-------------------------------------------+
  266. | VisualShaderNodeBooleanUniform | VisualShaderNodeBooleanParameter |
  267. +-----------------------------------------+-------------------------------------------+
  268. | VisualShaderNodeColorUniform | VisualShaderNodeColorParameter |
  269. +-----------------------------------------+-------------------------------------------+
  270. | VisualShaderNodeScalarUniform | VisualShaderNodeFloatParameter |
  271. +-----------------------------------------+-------------------------------------------+
  272. | VisualShaderNodeCubeMapUniform | VisualShaderNodeCubeMapParameter |
  273. +-----------------------------------------+-------------------------------------------+
  274. | VisualShaderNodeTextureUniform | VisualShaderNodeTexture2DParameter |
  275. +-----------------------------------------+-------------------------------------------+
  276. | VisualShaderNodeTextureUniformTriplanar | VisualShaderNodeTextureParameterTriplanar |
  277. +-----------------------------------------+-------------------------------------------+
  278. | VisualShaderNodeTransformUniform | VisualShaderNodeTransformParameter |
  279. +-----------------------------------------+-------------------------------------------+
  280. | VisualShaderNodeVec3Uniform | VisualShaderNodeVec3Parameter |
  281. +-----------------------------------------+-------------------------------------------+
  282. | VisualShaderNodeUniform | VisualShaderNodeParameter |
  283. +-----------------------------------------+-------------------------------------------+
  284. | VisualShaderNodeUniformRef | VisualShaderNodeParameterRef |
  285. +-----------------------------------------+-------------------------------------------+
  286. .. _doc_upgrading_to_godot_4_manual_rename:
  287. Manually renaming methods, properties, signals and constants
  288. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  289. Due to how the project upgrade tool works, not all
  290. :abbr:`API (Application Programming Interface)` renames can be performed automatically.
  291. The list below contains all renames that must be performed manually using the script editor.
  292. If you cannot find a node or resource in the list below, refer to the above
  293. table to find its new name.
  294. .. tip::
  295. You can use the **Replace in Files** dialog to speed up replacement by pressing
  296. :kbd:`Ctrl + Shift + R` while the script editor is open. However, be careful
  297. as the Replace in Files dialog doesn't offer any way to undo a replacement.
  298. Use version control to commit your upgrade work regularly.
  299. Command line tools such as `sd <https://github.com/chmln/sd>`__ can also be used
  300. if you need something more flexible than the editor's Replace in Files dialog.
  301. If using C#, remember to search for outdated API usage with PascalCase
  302. notation in the project (and perform the replacement with PascalCase
  303. notation).
  304. **Methods**
  305. - File and Directory classes were replaced by :ref:`class_FileAccess` and
  306. :ref:`class_DirAccess`, which have an entirely different API. Several methods
  307. are now static, which means you can call them directly on FileAccess or
  308. DirAccess without having to create an instance of that class.
  309. - Screen and window-related methods from the :ref:`class_OS` singleton (such as
  310. ``OS.get_screen_size()``) were moved to the :ref:`class_DisplayServer` singleton.
  311. Method naming was also changed to use the
  312. ``DisplayServer.<object>_<get/set>_property()`` form instead. For example,
  313. ``OS.get_screen_size()`` becomes ``DisplayServer.screen_get_size()``.
  314. - Time and date methods from the :ref:`class_OS` singleton were moved to the
  315. :ref:`class_Time` singleton.
  316. (The Time singleton is also available in Godot 3.5 and later.)
  317. - You may have to replace some ``instance()`` calls with ``instantiate()``. The
  318. converter *should* handle this automatically, but this relies on custom code that
  319. may not work in 100% of situations.
  320. - AcceptDialog's ``set_autowrap()`` is now ``set_autowrap_mode()``.
  321. - AnimationNode's ``process()`` is now ``_process()``
  322. (note the leading underscore, which denotes a virtual method).
  323. - AStar2D and AStar3D's ``get_points()`` is now ``get_points_id()``.
  324. - BaseButton's ``set_event()`` is now ``set_shortcut()``.
  325. - Camera2D's ``get_v_offset()`` is now ``get_drag_vertical_offset()``.
  326. - Camera2D's ``set_v_offset()`` is now ``set_drag_vertical_offset()``.
  327. - Camera2D's ``make_current()`` is now ``set_current()``.
  328. - CanvasItem's ``update()`` is now ``queue_redraw()``.
  329. - Control's ``set_tooltip()`` is now ``set_tooltip_text()``.
  330. - EditorNode3DGizmoPlugin's ``create_gizmo()`` is now ``_create_gizmo()``
  331. (note the leading underscore, which denotes a virtual method).
  332. - ENetMultiplayerPeer's ``get_peer_port()`` is now ``get_peer()``.
  333. - FileDialog's ``get_mode()`` is now ``get_file_mode()``.
  334. - FileDialog's ``set_mode()`` is now ``set_file_mode()``.
  335. - GraphNode's ``get_offset()`` is now ``get_position_offset()``.
  336. - GridMap's ``world_to_map()`` is now ``local_to_map()``.
  337. - GridMap's ``map_to_world()`` is now ``map_to_local()``.
  338. - Image's ``get_rect()`` is now ``get_region()``.
  339. - ItemList's ``get_v_scroll()`` is now ``get_v_scroll_bar()``.
  340. - MultiPlayerAPI's ``get_network_connected_peers()`` is now ``get_peers()``.
  341. - MultiPlayerAPI's ``get_network_peer()`` is now ``get_peer()``.
  342. - MultiPlayerAPI's ``get_network_unique_id()`` is now ``get_unique_id()``.
  343. - MultiPlayerAPI's ``has_network_peer()`` is now ``has_multiplayer_peer()``.
  344. - PacketPeerUDP's ``is_listening()`` is now ``is_bound()``.
  345. - PacketPeerUDP's ``listen()`` is now ``bound()``.
  346. - ParticleProcessMaterial's ``set_flag()`` is now ``set_particle_flag()``.
  347. - ResourceFormatLoader's ``get_dependencies()`` is now ``_get_dependencies()``
  348. (note the leading underscore, which denotes a virtual method).
  349. - Shortcut's ``is_valid()`` is now ``has_valid_event()``.
  350. - TileMap's ``world_to_map()`` is now ``local_to_map()``.
  351. - TileMap's ``map_to_world()`` is now ``map_to_local()``.
  352. **Properties**
  353. .. note::
  354. If a property is listed here, its associated getter and setter methods must
  355. also be renamed manually if used in the project. For example, PathFollow2D
  356. and PathFollow3D's ``set_offset()`` and ``get_offset()`` must be renamed to
  357. ``set_progress()`` and ``get_progress()`` respectively.
  358. - Control's ``margin`` is now ``offset``.
  359. - Label's ``percent_visible`` is now ``visible_ratio``.
  360. - MultiPlayerAPI's ``refuse_new_network_connections`` is now ``refuse_new_connections``.
  361. - PathFollow2D and PathFollow3D's ``offset`` is now ``progress``.
  362. - TextureProgressBar's ``percent_visible`` is now ``show_percentage``.
  363. - The ``extents`` property on CSG nodes and VoxelGI will have to be replaced
  364. with ``size``, with the set value halved (as they're no longer half-extents).
  365. This also affects its setter/getter methods ``set_extents()`` and
  366. ``get_extents()``.
  367. - The ``Engine.editor_hint`` property was removed in favor of the
  368. ``Engine.is_editor_hint()`` *method*. This is because it's read-only, and
  369. properties in Godot are not used for read-only values.
  370. **Enums**
  371. - CPUParticles2D's ``FLAG_MAX`` is now ``PARTICLE_FLAG_MAX``.
  372. **Signals**
  373. - FileSystemDock's ``instantiate`` is now ``instance``.
  374. - CanvasItem's ``hide`` is now ``hidden``. This rename does **not** apply to the
  375. ``hide()`` method, only the signal.
  376. - Tween's ``tween_all_completed`` is now ``loop_finished``.
  377. - EditorSettings' ``changed`` is now ``settings_changed``.
  378. **Constants**
  379. - Color names are now uppercase and use underscores between words.
  380. For example, ``Color.palegreen`` is now ``Color.PALE_GREEN``.
  381. - MainLoop's ``NOTIFICATION_`` constants were moved to global scope, which means
  382. you can remove the ``MainLoop.`` prefix when referencing them.
  383. - MainLoop's ``NOTIFICATION_WM_QUIT_REQUEST`` is now ``NOTIFICATION_WM_CLOSE_REQUEST``.
  384. Checking project settings
  385. ^^^^^^^^^^^^^^^^^^^^^^^^^
  386. Several project settings were renamed, and some of them had their enums changed
  387. in incompatible ways (such as shadow filter quality). This means you may need to
  388. set some project settings' values again. Make sure the **Advanced** toggle is
  389. enabled in the project settings dialog so you can see all project settings.
  390. Checking Environment settings
  391. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  392. Graphics quality settings were moved from Environment properties to project
  393. settings. This was done to make run-time quality adjustments easier, without
  394. having to access the currently active Environment resource then modify its
  395. properties.
  396. As a result, you will have to configure Environment quality settings in the
  397. project settings as old Environment quality settings aren't converted
  398. automatically to project settings.
  399. If you have a graphics settings menu that changed environment properties in
  400. Godot 3.x, you will have to change its code to call :ref:`class_RenderingServer`
  401. methods that affect environment effects' quality. Only the "base" toggle of each
  402. environment effect and its visual knobs remain within the Environment resource.
  403. Updating external shaders
  404. ^^^^^^^^^^^^^^^^^^^^^^^^^
  405. **Only shaders that are built-in to a scene file are modified by the project
  406. upgrade tool.** This means external shaders (saved to ``.gdshader`` files)
  407. need to be updated manually.
  408. The ``.shader`` file extension is also no longer supported, which means you must
  409. rename ``.shader`` files to ``.gdshader`` and update references accordingly in
  410. scene/resource files using an external text editor.
  411. Some notable renames you will need to perform in shaders are:
  412. - Texture filter and repeat modes are now set on individual uniforms, rather
  413. than the texture files themselves.
  414. - ``hint_albedo`` is now ``source_color``.
  415. - :ref:`Projection matrix variables were renamed. <doc_spatial_shader>`
  416. See :ref:`doc_shading_language` for more information.
  417. Updating scripts to take backwards-incompatible changes into account
  418. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  419. Some changes performed between Godot 3.x and 4 are not renames, but they still
  420. break backwards compatibility due to different default behavior.
  421. The most notable examples of this are:
  422. - Both :ref:`class_String` and :ref:`class_StringName` are now exposed to
  423. GDScript. This allows for greater optimization, as StringName is specifically
  424. designed to be used for "constant" strings that are created once and reused
  425. many times. These types are not equivalent to each other, which means
  426. ``"example" == &"example"`` returns ``false`` (``&`` creates a StringName).
  427. This should be taken into account for ``if`` and ``match`` comparisons in
  428. particular, as you may have to replace ``"example"`` with ``&"example"``.
  429. - :ref:`GDScript setter and getter syntax <doc_gdscript_basics_setters_getters>`
  430. was changed, but it's only partially converted by the conversion tool. In most
  431. cases, manual changes are required to make setters and getters working again.
  432. - :ref:`GDScript signal connection syntax <doc_gdscript_signals>` was changed.
  433. The conversion tool will use the string-based syntax which is still present in
  434. Godot 4, but it's recommended to switch to the :ref:`class_Signal`-based syntax
  435. described on the linked page. This way, strings are no longer involved,
  436. which avoids issues with signal name errors that can only be discovered at run-time.
  437. - Built-in scripts that are :ref:`tool scripts <doc_running_code_in_the_editor>`
  438. do not get the ``tool`` keyword converted to the ``@tool`` annotation.
  439. - The Tween node was removed in favor of Tweeners, which are also available in
  440. Godot 3.5 and later. See the
  441. `original pull request <https://github.com/godotengine/godot/pull/41794>`__
  442. for details.
  443. - ``randomize()`` is now automatically called on project load, so deterministic
  444. randomness with the global RandomNumberGenerate instance requires manually
  445. setting a seed in a script's ``_ready()`` function.
  446. - ``call_group()``, ``set_group()`` and ``notify_group()`` are now immediate by
  447. default. If calling an expensive function, this may result in stuttering when
  448. used on a group containing a large number of nodes. To use deferred calls like
  449. before, replace ``call_group(...)`` with
  450. ``call_group_flags(SceneTree.GROUP_CALL_DEFERRED, ...)`` (and do the same with
  451. ``set_group()`` and ``notify_group()`` respectively).
  452. - The ``rotation_degrees`` property was removed in favor of ``rotation`` property,
  453. which is still in radians but is automatically displayed as degrees in the
  454. editor. This breaks animations, as these are not converted automatically by the
  455. conversion tool.
  456. - :ref:`class_AABB`'s ``has_no_surface()`` was inverted and renamed to ``has_surface()``.
  457. - :ref:`class_AABB` and :ref:`class_Rect2`'s ``has_no_area()`` was inverted and
  458. renamed to ``has_area()``.
  459. - :ref:`class_AnimatedTexture`'s ``fps`` property was replaced by ``speed_scale``,
  460. which works the same as AnimationPlayer's ``playback_speed`` property.
  461. - :ref:`class_AnimatedSprite2D` and :ref:`class_AnimatedSprite3D` now allow
  462. negative ``speed_scale`` values. This may break animations if you relied on
  463. ``speed_scale`` being internally clamped to ``0.0``.
  464. - :ref:`class_BaseButton`'s signals are now ``button_up`` and ``button_down``.
  465. The ``pressed`` property is now ``button_pressed``.
  466. - :ref:`class_Camera2D`'s ``rotating`` property was replaced by
  467. ``ignore_rotation``, which has inverted behavior.
  468. - Camera2D's ``zoom`` property was inverted: higher values are now more zoomed
  469. in, instead of less.
  470. - :ref:`class_Node`'s ``remove_and_skip()`` method was removed.
  471. If you need to reimplement it in a script, you can use the
  472. `old C++ implementation <https://github.com/godotengine/godot/blob/7936b3cc4c657e4b273b376068f095e1e0e4d82a/scene/main/node.cpp#L1910-L1945>`__
  473. as a reference.
  474. - ``OS.get_system_time_secs()`` should be converted to
  475. ``Time.get_time_dict_from_system()["second"]``.
  476. - :ref:`class_ResourceSaver`'s ``save()`` method now has its arguments swapped around
  477. (``resource: Resource, path: String``). This also applies to
  478. :ref:`class_ResourceFormatSaver`'s ``_save()`` method.
  479. - A :ref:`class_StreamPeerTCP` must have ``poll()`` called on it to update its
  480. state, instead of relying on ``get_status()`` automatically polling:
  481. `GH-59582 <https://github.com/godotengine/godot/pull/59582>`__
  482. - :ref:`class_String`'s ``right()`` method `has changed behavior <https://github.com/godotengine/godot/pull/36180>`__:
  483. it now returns a number of characters from the right of the string, rather than
  484. the right side of the string from a given position. If you need the old behavior,
  485. you can use ``substr()`` instead.
  486. - ``is_connected_to_host()`` was removed from StreamPeerTCP and PacketPeerUDP as
  487. per `GH-59582 <https://github.com/godotengine/godot/pull/59582>`__.
  488. ``get_status()`` can be used in StreamPeerTCP instead.
  489. ``is_socket_connected()`` can be used in :ref:`class_PacketPeerUDP` instead.
  490. - In ``_get_property_list()``, the ``or_lesser`` property hint string is now ``or_less``.
  491. - In ``_get_property_list()``, the ``noslider`` property hint string is now ``no_slider``.
  492. - VisualShaderNodeVec4Parameter now takes a :ref:`class_Vector4` as parameter
  493. instead of a :ref:`class_Quaternion`.
  494. **Removed or replaced nodes/resources**
  495. This lists all nodes that were replaced by another node requiring different
  496. configuration. The setup must be done from scratch again, as the project
  497. converter doesn't support updating existing setups:
  498. +---------------------+-----------------------+----------------------------------------------------------------------------+
  499. | Removed node | Closest approximation | Comment |
  500. +=====================+=======================+============================================================================+
  501. | AnimationTreePlayer | AnimationTree | AnimationTreePlayer was deprecated since Godot 3.1. |
  502. +---------------------+-----------------------+----------------------------------------------------------------------------+
  503. | BakedLightmap | LightmapGI | See :ref:`doc_baked_lightmaps`. |
  504. +---------------------+-----------------------+ |
  505. | BakedLightmapData | LightmapGIData | |
  506. +---------------------+-----------------------+----------------------------------------------------------------------------+
  507. | BitmapFont | FontFile | See :ref:`doc_gui_using_fonts`. |
  508. +---------------------+-----------------------+ |
  509. | DynamicFont | FontFile | |
  510. +---------------------+-----------------------+ |
  511. | DynamicFontData | FontFile | |
  512. +---------------------+-----------------------+----------------------------------------------------------------------------+
  513. | Navigation2D | Node2D | Replaced by :ref:`other 2D Navigation nodes <doc_navigation_overview_2d>`. |
  514. +---------------------+-----------------------+----------------------------------------------------------------------------+
  515. | Navigation3D | Node3D | Replaced by :ref:`other 3D Navigation nodes <doc_navigation_overview_3d>`. |
  516. +---------------------+-----------------------+----------------------------------------------------------------------------+
  517. | OpenSimplexNoise | FastNoiseLite | Has different parameters and more noise types such as cellular. No |
  518. | | | support for 4D noise as it's absent from the FastNoiseLite library. |
  519. +---------------------+-----------------------+----------------------------------------------------------------------------+
  520. | ToolButton | Button | ToolButton was Button with the **Flat** property enabled by default. |
  521. +---------------------+-----------------------+----------------------------------------------------------------------------+
  522. | YSort | Node2D or Control | CanvasItem has a new **Y Sort Enabled** property in 4.0. |
  523. +---------------------+-----------------------+----------------------------------------------------------------------------+
  524. | ProximityGroup | Node3D | :ref:`class_VisibleOnScreenNotifier3D` can act as a replacement. |
  525. +---------------------+-----------------------+----------------------------------------------------------------------------+
  526. | Portal | Node3D | Portal and room occlusion culling was replaced by raster |
  527. | | | :ref:`occlusion culling <doc_occlusion_culling>` |
  528. | | | (OccluderInstance3D node), which requires a different setup process. |
  529. +---------------------+-----------------------+ |
  530. | Room | Node3D | |
  531. +---------------------+-----------------------+ |
  532. | RoomManager | Node3D | |
  533. +---------------------+-----------------------+ |
  534. | RoomGroup | Node3D | |
  535. +---------------------+-----------------------+----------------------------------------------------------------------------+
  536. | Occluder | Node3D | Geometry occlusion culling was replaced by raster |
  537. | | | :ref:`occlusion culling <doc_occlusion_culling>` |
  538. | | | (OccluderInstance3D node), which requires a different setup process. |
  539. +---------------------+-----------------------+ |
  540. | OccluderShapeSphere | Resource | |
  541. +---------------------+-----------------------+----------------------------------------------------------------------------+
  542. If loading an old project, the node will be replaced with its
  543. *Closest approximation* automatically (even if not using the project upgrade tool).
  544. **Threading changes**
  545. :ref:`Threading <doc_using_multiple_threads>` APIs have changed in 4.0. For
  546. example, the following code snippet in Godot 3.x must be modified to work in 4.0:
  547. ::
  548. # 3.x
  549. var start_success = new_thread.start(self, "__threaded_background_loader",
  550. [resource_path, thread_num]
  551. )
  552. # 4.0
  553. var start_success = new_thread.start(__threaded_background_loader.bind(resource_path, thread_num))
  554. ``Thread.is_active()`` is no longer used and should be converted to ``Thread.is_alive()``.
  555. .. seealso::
  556. See the `changelog <https://github.com/godotengine/godot/blob/master/CHANGELOG.md>`__
  557. for a full list of changes between Godot 3.x and 4.
  558. ArrayMesh resource compatibility breakage
  559. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  560. If you've saved an ArrayMesh resource to a ``.res`` or ``.tres`` file, the
  561. format used in 4.0 is not compatible with the one used in 3.x. You will need to
  562. go through the process of importing the source mesh file and saving it as an
  563. ArrayMesh resource again.
  564. List of automatically renamed methods, properties, signals and constants
  565. ------------------------------------------------------------------------
  566. The `editor/project_converter_3_to_4.cpp <https://github.com/godotengine/godot/blob/master/editor/project_converter_3_to_4.cpp>`__
  567. source file lists all automatic renames performed by the project upgrade tool.
  568. Lines that are commented out refer to API renames that :ref:`cannot be performed automatically <doc_upgrading_to_godot_4_manual_rename>`.
  569. Porting editor settings
  570. -----------------------
  571. Godot 3.x and 4.0 use different editor settings files. This means their settings
  572. can be changed independently from each other.
  573. If you wish to port over your Godot 3.x settings to Godot 4, open the
  574. :ref:`editor settings folder <doc_data_paths_editor_data_paths>` and copy
  575. ``editor_settings-3.tres`` to ``editor_settings-4.tres`` while the Godot 4
  576. editor is closed.
  577. .. note::
  578. Many settings' names and categories have changed since Godot 3.x. Editor settings
  579. whose name or category has changed won't carry over to Godot 4.0; you will
  580. have to set their values again.