upgrading_to_godot_4.rst 49 KB

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