Unity to Godot 4 - Top 8 Takeaways
I recently tried Godot 4 for the first time. Caveat is I may not know optimal ways to use Godot so may be overlooking or misinterpreting. Welcome comments and corrections. These are my top 5 takeaways:
(1) My biggest surprise was single threads across scenes (?). The documentation suggests you can do multiple threads for functions, but basic scene logic seems to be on a single thread (?). I have an enemy spawner and had a spawn loop which generates enemies if play mode is on.
while true:
if (!is_play):
continue
else:
# spawn stuff
However, this froze all other scenes. I had assumed that the spawner thread might get stuck but that other scenes and object would continue. I believe that the loop/continue was consuming all of the main thread. Adding a short timer to the loop worked.
await get_tree().create_timer(0.1).timeout
I think this is probably a hacky way to solve it, and perhaps signals or some other method other than looping to check state would be preferred.
I've read some conflicting info and am still trying to understand the Godot 4 thread model. https://docs.godotengine.org/en/stable/tutorials/performance/using_multiple_thre...
(2) GDScript was familiar to work with coming from a Python background (and C#, etc). The declaring variables without data types flexibility was interesting, but I know from past experience can lead to unexpected issues.
(3) Semantically, it took me a minute to consider "scenes" as prefabs in Unity, if I'm using them right.
(4) Node references through hierachies worked well. Still learning what is the optimal way to cross reference objects, accounting for performance. But I found it fairly intuitive how it supports direct or relative referencing.
if $PlayerAudioStream2D.playing == false:
player = get_node("/root/Player")
(5) The event system worked well. Shifting from Unity Events to Godot Signals was fairly straightforward. I liked how I could create a signal and Connect from the Inspector, connect it to another gd script, and it would generate the event handling function signature for me and place me in that script. From a workflow, it was helpful to create a signal and then immediately write the handler code. I didn't deep enough to know if I have to unsubscribe signals like I do with events in Unity.
(6) Collisions were similar to Unity. But I used a particular approach that I found in documents and tutorials to put a move and collide in the physics process _physics_process(). Normally in Unity, I handle movement and collision separately, so this was a bit strange to me. But I suspect there are other ways to setup.
var collision_info = move_and_collide(move_velocity * delta)
if collision_info:
handle_collision(collision_info)
(7) The most trouble I had was building for WebGL/HTML with Godot 4. It was helpful to indicate what libraries I needed and directly download. But I ran into loading issues (would take forever to load the last 10%). My researching suggested it could be the rendering or compression used. It seems there is a switch for GPU optimization which is now using its Vulkan implementation. I tried switching to Godot without C# version. I didn't want to switch down to 3.x because a lot of the code was written using 4. Still puzzled how to make a fast loading HTML version, given this project I tried was very light on resources but still took forever to load.
(8) Godot 4 is a lot different from Godot 3.x - Some of it is renamed methods, but there are a lot of replacements that made it confusing if I read other posts or tutorials. While this is somewhat expected, it seems like a lot of fundamental changes so be aware that even examples from a few months ago may not work. I found the Godot docs to be very helpful: https://docs.godotengine.org/en/stable/index.html
Overall, it was a positive experience trying Godot 4. I used for 2D, so didn't yet explore its 3D capabilities. It didn't feel quite as robust as Unity, but it made somethings like Events/Signals easy to setup, animations were pretty straightforward, and GDScript was familiar to Python. While Godot does support C# (something I want to try), I wanted to first see how their main scripting worked and I also believe there are some build limitations if you choose the C# version, but still learning. Not sure yet if I'll do more Godot or stick with Unity, but Godot had a lot of similarities after you learn their node concept and how they use scenes.
Leave a comment
Log in with itch.io to leave a comment.