I’ve been using Godot for a while now and I’m used to other engines such as Unity and Unreal as I use them daily for school.
However, recently I’ve researched on best practices, workflow and design of Godot but I stumbled uppon one big problem…
Godot is based on inheritance more than composition (you have nodes, but nothing that allow for single responsibility nodes equivalent to Unreal components; if you know a way to make this work, please, mention it), but GDScript being a duck typing language, it uses principles that better fit composition that inheritance.
Let’s say you have an ennemy class that represents all ennemies and a turret class that represents things that shoot bullets. Now, you want to create a tank that is an ennemy moving turret. How can you do that by being structuraly consistent and strong?
The problem here is that interfaces don’t exist in GDScript (nor multiple inheritance), so the contract design is not really strong. The best you can do is using the method “has_method” but then you have to hardcode a string and rely on a less performant system. If you try using composition instead, you are stuck with your tank that is either an ennemy OR a turret containing the other one or neither that contains both, hence the logic is spread everywhere and hard to maintain.
Of course, on such a small scale, using “has_method” is not too bad, but as the projet grows, it becomes more and more problematic.
Is there a good approach on this kind of problem with Godot? If so, what is it? Otherwise, why is Godot designed that way (using a weird mix between inheritance and composition designs) and are there plans to fix it or other solutions (forks, plugins, future version, etc.)?
- A serious video game student that want to use Godot for future potentially big projects