Introduction to Godot for engine developers

Trivia

Godot is a popular open source game engine that has gained a lot of attention in recent years. As of time of writing, it has 87.4k stars and more than 2.5k contributors on GitHub. It describes itself as a

Feature-packed, cross-platform game engine to create 2D and 3D games from a unified interface. It provides a comprehensive set of common tools, so that users can focus on making games without having to reinvent the wheel. 1

This description is general enough for any game engine out there, but the key points are “a set of common tools” and “without reinventing the wheel”. Unlike most of the new engines/frameworks out there, including raylib and bevy, that lavishly encourage developers to reinvent all kinds of wheels, Godot’s purpose, on the other hand, is to create a game in the fewest amount of steps possible.

Godot vs Unity

Although Unity’s aim is seemingly the same - to provide a set of tools so that game developers can make a game fast, its approach to this problem is opposite of Godot’s. Unity strives to be a general-purpose engine that Toftedahl and Engström describe in their Taxonomy 2 by providing virtually any feature that game developers might ever need, while Godot “intentionally does not include features that can be implemented by add-ons unless they are used very often”. 1 Instead, some core functionality is moved to officially supported add-ons, that can be imported to a new project with a click of a button. By doing this, project maintainers have a smaller and cleaner code base to work with, and users have easier time contributing - less information to learn and less time compiling. Of course this also means that 3D workspace tools are kept at medium and things like terrain editor or complex skeletal animation tools will need to be imported as plugins.

Engine Architecture

World editor

Ullmann and colleagues has found that Godot’s architecture contains all 16 out of 16 subsystems present in Gregory’s RTEA 3, which include a world editor (EDI). 4 In fact a world editor is implemented so impressively that even bevy’s creator can hardly help but to admire it 5, so we have no right taking a detour around it. Essentially a Godot editor is a game that runs on the Godot engine. There is a built-in code editor and many other features present in most of the engines’ editors, but what is a fairly novel strategy is that Godot uses its own user interface toolkit. This means that users use the same code and scenes both to build games and to build plugins to extend the editor (without reloading the editor). This practice of using its own tool is called “eating your own dog food” which serves as a quality control for UI toolkit, because “editor itself is one of the most complex users of Godot’s UI system.” 1 Another feat of the editor is having an experimental support for Android and web browsers, which means that users can work on a game from virtually anywhere.

Language

Godot is written in C++ and for scripting it uses its own scripting language GDScript, designed specifically for the needs of game developers and game designers. It is also optimized for gameplay code with built-in types like Vectors and Colors and easy support for multithreading. But GDScript is not the only possible choice, there is support for C# with .NET as well other languages like C, C++, Rust, Swift and others via GDExtension.

Easy multithreading

One last thing to keep in mind about the architecture is the use of Servers to provide multithreading capabilities. Most engines use job scheduling technique for concurrency, but it is a rather complex approach that sacrifice ease of use as it does not protect the code that is being modified in a separate thread, so users need to manually manage mutexes or semaphores. Servers solve this problem by not requiring threads to sync by the end of each frame - a Server with Logic and Physics can run on a current frame while Rendering can be processed a frame later. 6 By taking most of the responsibilities of concurrency on itself, users have easier time writing multithreaded code, but this tradeoff can potentially cause one-frame-off lags.

Game world model

For the game world model, instead of ECS (Entity Component Systems), Godot uses OCM (Object Component Model) and makes heavy use of inheritance (data-oriented optimizations are still present for physics, rendering, audio, etc., but they are separate systems and completely isolated). Original authors came to the conclusion that this leads to better usability for users while still being performant in most use cases:

Inheritance is more explicit - what would be implicit relationships between components in ECS, are now explicit in the inheritance chain. This makes it very easy to understand how the scene nodes are organized and what they can do, by just looking at the inheritance tree. 7

The smallest building block of a game is called Node and other game objects inherit from it, akin to Unreal’s CoreUObject. It contains both data and logic. One or more Nodes can form a Scene. A Scene can be a character, a weapon, a menu or an entire level. It works the exact same way as a class in pure code, except that it can be designed both in the editor and in the code. 1

Thanks to everything being nodes (and not entities with components) it becomes easier to reuse and combine everything as much as possible - Godot does not distinguish between scenes and prefabs. Scene is simply a bunch of nodes forming a tree, which are saved in a text file. Scenes can be instantiated and inherited. 7

When some event occurs to a Node (e.g. objects collided, something needs to be repainted, button was pressed, etc.), it can emit a Signal to send information to other Nodes. This feature allows them to communicate without being hard-wired in code. In Godot’s game world model, Nodes are just interfaces to the actual data being processed inside Servers, while in ECS the systems process entities (data) directly. 7

If Node is a base building block of a game then Object is a base building block of the engine - all other classes inherit from Object, including Node. A custom Node can be derived from Object with new properties, methods or signals which can drastically change the organization of a game. Another important class is Variant, which is a container that can store almost any engine datatype inside of it. This is what allows GDScript to be dynamically typed, and its main purpose is to communicate, edit and move data around rater then to store it persistently. 1

Target platforms & graphics

A list of supported target platforms is standard - Windows, Linux and MacOS desktops, Android, iOS and web. An achievement worth mentioning a second time is that an editor also runs on Android and Web browsers, not just on desktop. It is quite featureful and includes a code editor, an animation editor, a tilemap editor, a shader editor, a debugger, a profiler, and more. Godot also allows creating non-game applications thanks to the built-in UI system that can replace other toolkits like Qt, GTK or Electron. 1 The quality of graphics is obviously hardware dependent, but the engine supports 3 rendering methods with varying degree of graphics options diversity:

  • Forward+ will use Vulkan API with all features;
  • Forward Mobile - is slightly handicapped version of former to allow drawing simple scenes faster;
  • Compatibility will use OpenGL backend which is more suitable for low-end devices.

Conclusion

As a culmination for good design decisions, Godot’s community is flourishing like no other and despite being much younger than Unity or Unreal, can already compete with them in terms of user-generated tutorials and free assets. Asset store hosts more than 3k officially supported plugins that either extend the editor’s functionality or contain entire demo projects, all of which are free to use.

Godot is made by its community, for the community, and for all game creators out there. 1

Whenever users need a new feature to be merged into the engine’s core, open discussions take place to decide whether a particular addition will benefit the most users first. 1 This openness to public prevents adding features for the sake of satisfaction of the corporate greed like “Runtime Fee” in Unity. 8

Overall, Godot is the most pleasant engine that I had to work with. It is simple to learn and simple to use. Both the documentation and the API reference are incredibly informative without being too overwhelming, both of which can be accessed within the editor. To conclude, here is what Juan Linietsky, Godot’s original developer, writes about his vision for the engine:

Godot as an engine tries to take the burden of processing away from the user, and instead places the focus on deciding what to do in case of an event. This ensures users have to optimize less in order to write a lot of the game code, and is part of the vision that Godot tries to convey on what should constitute an easy to use game engine. 7