How come this post
Godot 4 has its first release candidate on Feb, 8, 2023. I downloaded it and experimented with Godot 4 these days. I tried to convert Thrive to Godot 4 as well but failed (Or stuck, to be concise).
I’d like to list Pros and Cons of switching to Godot 4 here (and list some actions needed) for discussion, and aid anyone who wants to switch Thrive to Godot 4 (or 4.1 or anything).
Overview
I got 2400+ errors after using builtin Godot project converter. Some scene related things are also broken.
Cool features provided by Godot 4
No need for NodePath!!!
Godot 4 supports exporting GodotObject, so there is no longer a need for all those NodePath, Nullable checks and Disposals.
No more unhandled exceptions
Godot now handles any user-unhandled exception for us, the game will not crash due to our fault. Instead, it will print an error:
ERROR: System.NullReferenceException: Object reference not set to an instance of an object.
at Main.DialogOpenRequested() in /home/ajax/TestGodot4/Main.cs:line 24
at Main.InvokeGodotClassMethod(godot_string_name& method, NativeVariantPtrArgs args, godot_variant& ret) in /home/ajax/TestGodot4/Godot.SourceGenerators/Godot.SourceGenerators.ScriptMethodsGenerator/Main_ScriptMethods.generated.cs:line 34
at Godot.Bridge.CSharpInstanceBridge.Call(IntPtr godotObjectGCHandle, godot_string_name* method, godot_variant** args, Int32 argCount, godot_variant_call_error* refCallError, godot_variant* ret) in /root/godot/modules/mono/glue/GodotSharp/GodotSharp/Core/Bridge/CSharpInstanceBridge.cs:line 24
at: godotsharp_pusherror (modules/mono/glue/runtime_interop.cpp:1303)
C# action implementations
Godot added C# action implementations to signals, making all Node-derived classes partial. Now we can use Button.Pressed += Handler
to connect to signals (Also this is now the recommended way); However, they removed signal bindings when connecting signals from C# and altered binding format, from Node.Connect(sig, obj, fun, binding, mode)
to Node.Connect(sig, tgt, mode)
where tgt = (obj, fun)
. So bindings have to be moved to calls.
Autowrap to all Dialogs
Now autowrap function is moved from WindowDialog to Window (now the hierarchy is Popup <- Window <- Viewport <- Node
and AcceptDialog <- Window <- Viewport <- Node
), so the major part of CustomDialog is now redaudant.
Difficulties to convert to Godot 4
Joybad rework
There’re MASSIVE changes to the Joy-pad controls, from JoystickBlaBla
to JoyAxis
and JoyButton
, so someone very familiar to joypad has to rework this part.
_Process rework
_Process(float delta)
goes to _Process(double delta)
, generating numerous type conversions.
Tween rework
Tween is no longer Node
so tween usage should be reconsidered.
Signal rework
No connect-time signal binding anymore. (Mentioned above)
EDIT: From Add a project upgrade tool for Godot 4.0 · Issue #387 · godotengine/godot-proposals · GitHub
conversion of
connect()
to the new syntax?other.connect("signal", target, "method", [binds])
becomesother.signal.connect(target.method).bind(binds)
. This is handled in my converter, but the official one handles connections in a different way (which works), so it’s ok too
EDIT 2: It’s BRILLIANT! No proxy anymore (maybe)
control.Connect("focus_entered", GUICommon.Instance, nameof(GUICommon.ProxyFocusForward)),
new Array(control));
goes to
control.FocusEntered += control.ForwardFocusToNext;
Popup rework
Due to the fact that Popup is no longer CanvasItem, it has no Draw calls. Many custom Popups need to be reworked.
Project conversion errors
We may need to choose a good project converter to avoid renaming all Path
to Path3D
, all Remove
to RemoveAt
…
Scene errors
AFAIK thrive_theme.tres is not converted properly. e.g. Button styleboxes are missing.
Other changes
-
ColorPicker is completely reworked too
-
Dotnet nullable updates
-
Added Vector2I (<int, int>) for controls (more type conversions)
-
File and Directory reworks (this looks good)
Personal thoughts
It will be pretty hard to switch to Godot 4. However, GUI programming will be benefitted a lot because I think Godot 4’s C# logic is more native and clear.