In the process of porting my Unity code to Godot, I have compiled notes of the common translations from Unity code patterns into the new Godot C# patterns here. Hopefully this will be helpful.
Not bad except
Awake() is more like
Start() is more like
Awake will be called regardless if the instantiated object is disabled or not, so it works almost like a constructor.
Start on the other hand may or may not be called depending if the object is disabled or not. If I remember correctly it will be called again after re-enabling.
_Init() acts as a constructor, it will always be called when an node/scene is instantiated.
_Ready() on the other hand is called only when the node is added to the tree and all of its children are ready, so this function may not be called if you never add the instantiated object to the tree.
Very similar, as you can see.
Godot really has no concept of “enabled” nodes so it’s really hard to map then 1:1. One way nodes can be disabled is by removing them from the tree. When they are re-added, only _enter_tree is called again, whole ready won’t be called again.
Fair warning, I’m always sceptical about drawing generic parallels between X and Y techs. It’s often more hurtful than helpful, since you’re trying to see Y through the lens of X, and this lens only.
I don’t think trying to match Unity components and Godot nodes lifecycles is doing any favour to anybody.
_Ready() is not comparable to
Awake() nor is it to
Start(). Pushing a square peg in a round hole doesn’t make it round.
The part about “Godot type name conflicts” really is not that specific to Godot at all. It’s possible to shadow names in C#. Using namespaces, or fully qualifying types is the answer, regardless of the engine (or lack thereof).
If you have issues with VSCode and Intellisense, just uninstalling and reinstalling the SDK won’t resolve them. We go through a lot of users with environment/setup issues on other platforms (e.g. Discord). It’s usually not very complicated to figure out the issues (granted the right info is provided, we have a script users can run for that). But if this is supposed to be a reference document for other users, I’d be weary about putting unverified info in there.
The thread should probably be tagged in csharp
I’m really just trying to help Unity developers move their code to Godot. So it’s not about making parallels as much as it is helping people rewriting existing code they’ve already written. Which I’m currently doing as I have a bunch of Unity code and I want to see if Godot is a better solution for new projects.
I’m happy to update the documentation, but I did a lot of reading on
_Ready and it seems that it is similar to Awake? Or am I missing something? _Ready is called from the child node to the parent node, so couldn’t you use it in the same way you use Awake in Unity? I would assume that the entire tree of nodes is already in existence when _Ready is called, or is that incorrect?
One thing I realized as a Godot advantage is that Godot is using .Net instead of Mono, which means that Godot C# devs can use the new C# 10 features, but Unity devs can’t.
This creates an issue in trying to write code that works for both.