Game Development Using the Open-Source Godot Game Engine - Tero Salmela BACHELOR'S THESIS - Theseus

Page created by Rosa Mendoza
 
CONTINUE READING
Game Development Using the Open-Source Godot Game Engine - Tero Salmela BACHELOR'S THESIS - Theseus
Game Development Using the
Open-Source Godot Game Engine

Tero Salmela

BACHELOR’S THESIS
May 2022

Degree Programme in Media and Arts
Interactive Media
Game Development Using the Open-Source Godot Game Engine - Tero Salmela BACHELOR'S THESIS - Theseus
ABSTRACT

Tampereen ammattikorkeakoulu
Tampere University of Applied Sciences
Degree Programme in Media and Arts
Interactive Media

SALMELA, TERO:
Game Development Using the Open-Source Godot Game Engine

Bachelor's thesis 67 pages, of which appendices 2 pages
May 2022

This bachelor’s thesis examined the open-source video game development tool,
Godot Engine. The popularity and viability of independent game development is
growing along with the many software tools available for developers today. This
thesis focused on the potential of Godot Engine for game development, its
design, features and workflows.

Evaluating Godot Engine in this thesis was done in multiple ways. Godot Engine
was compared to the popular alternatives, Unity and Unreal Engine. Godot En-
gine’s history, design, features and community were examined. Godot Engine’s
numerous features for graphics, physics, programming, animation, audio and
networking were highlighted.

This thesis includes a practical project, which was created using Godot Engine.
The goal of the practical part was to provide a closer look at the structure of a
project in Godot Engine, and to showcase common workflows associated with
the program. The project results were examined in detail, with examples of
design, programming and features covered. The project was publicly released
as open-source software for further reference and study.

A concluding discussion on the merits of Godot Engine as an independent
game development tool was written to conclude the thesis work. Along with this,
a reflection on the practical project, and some details about future develop-
ments and trends were included.

Key words: godot engine, game development, game design, software,
programming
Game Development Using the Open-Source Godot Game Engine - Tero Salmela BACHELOR'S THESIS - Theseus
3

CONTENTS

1 INTRODUCTION................................................................................6
    1.1 Motivation for the thesis..............................................................6
    1.2 Goal of the thesis........................................................................7
2 GAME ENGINES................................................................................8
    2.1 Unity Introduction........................................................................10
    2.2 Unreal Engine Introduction.........................................................11
    2.3 Godot Engine Introduction..........................................................12
3 GODOT ENGINE................................................................................14
    3.1 History.........................................................................................14
    3.2 Design.........................................................................................15
    3.3 Features......................................................................................16
          3.3.1 Godot Editor......................................................................16
          3.3.2 Nodes and scenes............................................................17
          3.3.3 Graphics...........................................................................18
          3.3.4 Physics..............................................................................19
          3.3.5 Scripting............................................................................19
          3.3.6 Animations........................................................................21
          3.3.7 Audio.................................................................................21
          3.3.8 Networking........................................................................22
          3.3.9 Asset workflow..................................................................23
          3.3.10 Platform support.............................................................24
    3.4 Community..................................................................................25
4 GAME PROJECT...............................................................................27
    4.1 Island Assault.............................................................................27
    4.2 Structure.....................................................................................28
    4.3 Player controller..........................................................................31
    4.4 Level...........................................................................................38
    4.5 Enemies......................................................................................42
    4.6 User interface.............................................................................45
    4.7 Score..........................................................................................47
    4.8 Effects and audio........................................................................49
    4.9 Persistent data............................................................................51
5 DISCUSSION......................................................................................53
    5.1 Godot Engine for independent game development...................53
    5.2 Practical project..........................................................................55
    5.3 The future of Godot....................................................................57
Game Development Using the Open-Source Godot Game Engine - Tero Salmela BACHELOR'S THESIS - Theseus
4

    5.4 Conclusion..................................................................................59
REFERENCES......................................................................................61
APPENDICES........................................................................................66
    Appendix 1. Project repositories.......................................................66
    Appendix 2. Asset sheet...................................................................67
Game Development Using the Open-Source Godot Game Engine - Tero Salmela BACHELOR'S THESIS - Theseus
5

ABBREVIATIONS AND TERMS

2D, 3D               Two-dimensional, three-dimensional.
GDScript, C#, C++,   Programming languages.
Python
OpenGL               Open standard, cross-platform API for 3D graphics
                     developed by the Khronos Group.
GLES2, GLES3         Versions of OpenGL for Embedded Systems.
GLSL                 OpenGL Shading Language.
HUD                  Heads-up display. Gives visual information about
                     status in a game.
UI                   User interface.
API                  Application Programming Interface. Interface for
                     communication with software via code.
Vulkan               Open standard, cross-platform API for 3D graphics
                     developed by the Khronos Group. Supersedes
                     OpenGL.
6

1 INTRODUCTION

1.1 Motivation for the thesis

Ever since my youth, I’ve held a fascination for games and the tools used to
create them. Even before I knew how to use a computer, I would come up with
ideas for games that I would like to make. I started out creating my first games
with a program called Klik & Play (Clickteam 1994), which was an easy-to-use
game creation software. Ever since then, I have learned about and used many
programs to create games.

Around the end of 2016, I found out about Godot Engine, a free and open-
source game engine. We had been working on some game projects at my com-
pany using various game development tools, like Unity. We were looking for a
tool that better fit our needs and decided to try out Godot Engine. We have
been using Godot ever since and worked on multiple different types of projects
with it.

I attended the TAMK Games Academy in 2019/2020 and worked on two pro-
jects using Unity. I hadn’t used Unity in a while at this point and had never gone
too deep, especially with regard to programming and technical implementations.
After my experience with Unity during this time, I started to reflect more on how
all of these tools have differing approaches, benefits and trade-offs in their
design and features.

While following online game development-related forums, I commonly en-
countered questions about what software or methods were recommended for
developing games. My experiences with some of these programs in the past,
along with my recent work with Godot Engine and Unity, made me interested in
examining these tools in closer detail.
7

1.2 Goal of the thesis

The main objectives of this thesis work are to examine Godot Engine as a game
development tool, to compare its design and capabilities to other similar tools,
to provide examples of how it works in practice and to evaluate its position in
the game development tools ecosystem. While the main focus of this thesis is
Godot Engine itself, I will examine some other tools as well. While considering
that I’m very familiar with Godot and prefer many of its approaches, I will try to
keep an open mind and have an objective approach to the other tools discussed
along the way.

This thesis includes a practical section that consists of examining a game pro-
ject created using Godot Engine. This game serves as a means of showcasing
certain aspects of Godot and providing a more practical approach to under -
standing its design. Godot Engine has features for developing both 2D and 3D
games, but for this project I decided to focus on 2D. The project is an arcade
style 2D game, and I have attempted to design it to showcase a variety of fea-
tures and aspects of Godot.

My hope is that this thesis will provide a good overview of Godot Engine for
those unfamiliar with it, provide some context to compare it to other tools, like
Unity, and to inspire others to try it by showing how games are created with it. I
personally believe Godot is a great tool for certain projects and I hope that this
thesis will show some of the reasons why.
8

2 GAME ENGINES

Many different types of game development tools have been created and used
by game developers over the last decades. The idea of a modern game engine
came about in the 90s, with the release of games like id Software’s Doom in
1993. The idea of separating the core functionality of a game’s engine techno-
logy and its content was a new approach at the time. (Gregory 2015, 11.)

Since then, many general-purpose game engines have been developed. Cur-
rently, the two major players in the proprietary game engine business are Unity
and Unreal Engine (CB Insights 2018). Some other popular commercial game
engines include GameMaker, RPGMaker, Construct and CryEngine. Some free
and open-source game engine projects also exist, such as Godot Engine, Stride
(formerly known as Xenko) and Bevy.

To get a better understanding of the popularity of these different engines, it can
be helpful to look at some usage statistics. According to the website SteamDB
(2022b), which offers a tracker attempting to detect what game engines are
used by games on the popular digital distribution platform Steam. This first table
shows the top technologies in use and the number of detected games (Table 1).

TABLE 1. Game technologies used on Steam according to SteamDB (2022b)
  Technology       Total games       Proportion (of listed)
  Unity            28 774            64,40%
  Unreal           7 370             16,49%
  GameMaker        3 043             6,81%
  RPGMaker         2 076             4,65%
  RenPy            1 347             3,01%
  XNA              582               1,30%
  Godot            455               1,02%
  Adobe AIR        401               0,90%
  Cocos2d          346               0,77%
  MonoGame         289               0,65%
9

While it is important to keep in mind that these numbers might not be com-
pletely accurate as the source itself warns, it can still be helpful for making
some conclusions. The overwhelming popularity of Unity is clear, likely fuelled
by the large number of indie games released on Steam. According to SteamDB
(2022a), the most popular tag used on the platform is “Indie” with 62 673 tagged
products at the time of writing.

One thing that these previous statistics do not reveal is trends. For example,
Godot Engine was publicly released only in January of 2014 (Linietsky 2014)
and did not grow much in popularity until recently. To see some evidence of this
recent surge in Godot’s popularity, there are some statistics that can be looked
at. Game jams, event’s where indie developers make small games in a limited
time for friendly competition, can be used for this data. This table tracks the pro-
portion of Godot Engine submissions in the annual Global Game Jam (Table 2).

TABLE 2. Proportion of Godot Engine submissions in Global Game Jam (2022)
  Year        Total games      Godot games       %
  2018        8582             95                1,11
  2019        9000             191               2,12
  2020        9598             358               3,73
  2021        6381             312               4,89
  2022        5858             294               5,02

While the amount of Godot games participating in 2022 is still just five percent,
there is a clear trend of growing proportional popularity among the submissions.
This, along with the data from SteamDB discussed earlier, shows that Godot
Engine still remains a relatively unpopular choice among some the other tools
examined here.

The goal of this brief overview into some of the history and statistics of game
engines, and of Godot Engine in particular, is to provide some idea of the game
development software ecosystem as it stands today. The next sections will
provide some more detail about the most popular engines, Unity and Unreal En-
gine, along with a brief introduction to Godot Engine.
10

2.1 Unity Introduction

Unity is a commercial game engine developed by Unity Technologies. Unity is
utilized in a variety of interactive real-time applications and has extensive sup-
port for different platforms. Unity has been used to create many massively suc-
cessful games, such as Genshin Impact, Fall Guys: Ultimate Knockout, Escape
from Tarkov, Valheim and Hollow Knight. (Unity 2022c.)

Unity offers a feature-rich editor for creating levels and assets and managing
projects. Unity has a package management system that allows you to pick and
choose the features and functionality relevant to your project, such as various
2D and 3D features, editor tools and platform plugins (Unity Docs 2022c). Unity
also operates the Unity Asset Store for graphics, sounds, tools and plugins us-
able in projects through the package manager (Unity 2022a).

Scripting in Unity is done using Microsoft’s C# programming language. Unity
has a compositional “GameObject” system, where each object can contain mul-
tiple different components that combined define the object’s behaviour (Unity
Docs 2022a). Unity comes with many basic components for graphics rendering,
physics, user interfaces and sound. These built-in components can then be
combined with custom script components to create complex behaviours.

Unity has two primary rendering pipelines, the Universal Render Pipeline or
URP, with a focus on performance along with a wide platform compatibility, and
the High Definition Render Pipeline or HDRP, with a focus on high-end graph-
ical fidelity for modern PCs and consoles. Both of these rendering pipelines of-
fer physically based rendering, lighting, particles and post-processing. Unity
also features 2D specific graphics features, like 2D lights. (Unity Docs 2022b.)

Unity has a user manual and a scripting reference available for developers. Due
to its popularity, Unity has a large community of developers and content creat-
ors forming an unofficial support network for Unity developers. Unity being a
commercial product used by many professionals, there are also forms of
premium support available for companies using Unity. (Unity 2022b.)
11

2.2 Unreal Engine Introduction

Unreal Engine is a commercial game engine developed by Epic Games. Unreal
Engine has a storied history, having been used by many studios to create nu-
merous iconic games (GameForest 2018). Modern examples of successful Un-
real Engine games include Final Fantasy VII Remake, PUBG: BATTLE-
GROUNDS, the Borderlands series, Tekken 7 and Epic Game’s own Fortnite.
(Unreal Engine 2022b.)

Unreal Engine offers a feature-rich editor with a set of tools for creating levels,
adding functionality and managing assets. The engine also comes with some
templates for games, supporting a few common genres like first person shoot-
ers, and other interactive projects such as industrial visualization (Unreal En-
gine Docs 2022d). Similar to the Asset Store for Unity, Unreal also has the Un-
real Engine Marketplace for purchasing and downloading assets, templates and
plugins for use in your projects (Unreal Engine 2022c).

Unreal Engine uses the C++ programming language for scripting behaviours,
but also offers the extensive visual scripting system Blueprints as a more non-
programmer friendly alternative (Unreal Engine Docs 2022c). Just like Unity,
Unreal Engine also supports a component system, where components can be
added to objects called “Actors” in the engine to extend behaviour. Unreal En-
gine also provides a range of built-in components, much like those of Unity.
(Unreal Engine Docs 2022a.)

The graphical features of Unreal Engine provide support for the most high-end
features used by modern AAA games, such as ray tracing. Complex particle ef-
fects and other visual effects are supported, as is a wide variety of physics sim-
ulation features. Just like Unity, Unreal Engine features a physically based ap-
proach to rendering materials and lighting. (Unreal Engine Docs 2022b.)

Unreal Engine has similar levels of platform support as Unity, both having been
used to create very successful mobile games like PUBG Mobile and Genshin
12

Impact respectively. Unreal Engine provides some documentation, along with
community-based and premium support for users like those existing for Unity
(Unreal Engine 2022a). Due to the popularity metrics discussed previously, Un-
real Engine doesn’t have as large of an independent developer community sur-
rounding it as that of Unity.

2.3 Godot Engine Introduction

Godot Engine is a free and open-source game engine developed and main-
tained by a community of independent contributors. Godot Engine is licensed
under the MIT license and the project is a member of the Software Freedom
Conservancy non-profit. Not many successful games made with Godot exist,
but to mention a few examples, there is Cruelty Squad, Beat Invaders, Wrought
Flesh and the upcoming Ex-Zodiac, Kingdoms of the Dump and FRANZ FURY.
Perhaps the first example of a larger studio using Godot was when it was re-
vealed that the recently released Sonic Colors: Ultimate was using Godot En-
gine under the hood (Gutiérrez 2021). (Godot Engine 2022c.)

The Godot Engine editor features tools for creating content, managing assets
and also includes a built-in scripting editor. Unlike Unity and Unreal, Godot does
not use a component-based approach, but rather has different classes of ob-
jects called nodes. There are many types of nodes for graphics, physics, user
interface and audio, much like the components in an engine like Unity. Nodes
are arranged in a scene hierarchy to create more complex behaviour. (Godot
Docs 2021j.)

A script can be attached to any node to extend its behaviour. Godot Engine has
a purpose-built scripting language called GDScript, which is similar in its syntax
to Python (Godot Docs 2022b). Godot Engine also features first-class support
for C#, a basic visual scripting system and the option of scripting in Godot’s nat-
ive C++ language (Godot Docs 2020). Godot Engine also features an imple-
mentation of the observer pattern, as described in Game Programming Patterns
by Robert Nystrom (2014, II.4.) in what are called signals in Godot (Godot Docs
2021j).
13

Godot Engine has separate 2D and 3D rendering pipelines. The 3D rendering
follows a physically based approach to shading and lighting, featuring most of
the commonly used features available in Unity and Unreal. The 2D rendering
also has some specific features, like 2D lighting, masking and shadows. Godot
Engine also features both 2D and 3D physics features for simulations, triggers
and ray casting. (Godot Docs 2022d.)

Project export support in Godot Engine is available for desktop platforms, mo-
bile and web (Godot Docs 2022d). Exporting Godot projects to consoles will be
discussed more in the next part of this thesis. As an open-source project, Godot
relies on a community of enthusiasts to support its development and the de-
velopers using it. Godot Engine has a detailed official documentation available
as well as a public GitHub page hosting the source code. There are numerous
community platforms dedicated to Godot Engine. (Godot Engine 2022b.)

This short introduction to Godot Engine will be expanded upon in the next part
of this thesis. More comparisons of specific aspects of Godot to other tools will
be covered as relevant. As evident by the introductions in this section, much of
the functionality of game engines is similar in nature. There are some differ-
ences in approach and design that have their trade-offs. These brief introduc-
tions are only scratching the surface of these complex pieces of software.
14

3 GODOT ENGINE

3.1 History

Godot Engine started as an in-house engine developed by two Argentinians,
Juan Linietsky and Ariel Manzur. After years of working as consultants for game
technologies and developing their own engine in the early 2000s, the engine
was open sourced in early 2014. (Linietsky 2019.)

Due to the instability of the industry in Argentina, the two developers split ways
and Godot became more of a hobby for lead developer Juan Linietsky, while he
continued working in consulting. There were little contributions from anyone at
first, with Juan himself fixing issues users were reporting. After a while, in
December 2014, the 1.0 version of Godot Engine was released. (Linietsky
2019.)

Godot 2.0 was released in early 2016, and when the 2D side of Godot was
starting to mature, more focus was put on the 3D aspects of the engine. Rémi
Verschelde joined Juan as a project manager in 2015 to manage the growing
number of contributors to the project. Since the engine was not used as an in-
house tool anymore, a lot of much needed compatibility breaking changes could
finally be implemented. Finishing the 3.0 version took much longer than expec -
ted and brought along with it physically based rendering for 3D, when it finally
released in January 2018. (Linietsky 2019.)

With the community growing and more revenue coming in through donations
and sponsorships, core members of the development team could finally be
hired to work full-time on Godot and contributors could be hired for part-time
projects. By the turn of the decade, there was a need for another massive re-
write of many core aspects of the engine. A new Vulkan-based renderer is be-
ing implemented as are many other changes to the core systems, scripting lan-
guage, lighting and usability in the upcoming 4.0 release. (Linietsky 2019.)
15

3.2 Design

Godot Engine has a general focus on being an accessible, open, community-
driven and powerful game engine. To accommodate these goals for the project,
a few unorthodox design decisions are implemented that set Godot apart from
some of the competition. Since the project is more tightly linked to its open-
source community than a traditional commercial game engine, the direction of
the engine is driven by this community. Despite all of the developments, some
core aspects are likely to remain a staple of the engine. (Godot Docs 2021h.)

In contrast to Unity, Unreal and many other engines, Godot embraces some
more traditional object-oriented approaches. Most modern engines use some
kind of a component system as a means of decoupling as described by Robert
Nystrom in Game Programming Patterns (2014, V.14.). In Godot, each object or
node can only be of one type and have one script attached. You can compose
nodes together to create reusable scenes, which behave much like nested pre-
fabs do in Unity. Godot also has a stronger focus on inheritance, as these
scenes and scripts can be extended to create more variations. (Godot Docs
2021h.)

Godot Engine is designed to include the most commonly used tools, tightly in-
tegrated to form a fully-featured package, while avoiding adding features that
are not as frequently used into the core of the engine (Godot Docs 2021h). This
somewhat tight control has had its benefits, as for example the engine down-
load is less than a hundred megabytes in size and runs as a single executable
file with no installation required. Addons from the Godot Asset Library can be
used to add additional features as needed. (Godot Engine 2022a.)

Since Godot Engine is an open-source project, it is important that there are con-
tributors active and willing to work on the project. Contributions to the code have
to be reviewed for quality, readability and usefulness by other developers before
they can be implemented in the engine. Documentation and testing are also
community-driven. Everyone benefits from any updates to the project and this
open nature is one of the defining aspects of Godot. (Godot Docs 2021e.)
16

3.3 Features

Godot Engine is a fully-featured game engine with tools for creating 2D and 3D
games. There are many features for rendering graphics, interactivity, user inter-
face, physics simulations, particle effects and shaders, programming beha-
viours, networking, audio and asset management. This section will highlight
some of the most important features of Godot. (Godot Docs 2022d.)

3.3.1 Godot Editor

All of the Godot Engine features can be used through the Godot Editor. This
program contains the scene tree view and viewport where you can hierarchic -
ally and visually develop your scene files. The editor also contains the inspector
used to edit node parameters and the file system explorer to manage project
files. There are tabs for the 2D editor, 3D editor, script editor and asset library
browser, as well as expandable tabs for the console output, debugger, audio
mixer and animation editor. Here is a screenshot of the default layout of the
Godot Editor (Picture 1). (Godot Docs 2021g.)

PICTURE 1. A screenshot of the Godot Editor viewing the official Third Person
Shooter Demo project.
17

3.3.2 Nodes and scenes

In the Godot Engine development environment, nodes are the basic building
blocks of programs, similar to Unity’s GameObjects. Unlike in Unity, where you
attach different components to make GameObjects unique, Godot comes with
many different types of nodes, each designed for a different purpose and utiliz -
ing different engine features. Most nodes in Godot are arranged under three
main categories, Spatial for 3D related nodes, Node2D for 2D related nodes
and Control for user-interface related nodes. (Godot Docs 2021j.)

Nodes are arranged hierarchically in what are called scenes in Godot, much like
the scenes in Unity. Unlike in Unity, there is no separate prefab system, but in -
stead all scenes can be freely combined, instanced and inherited from. The par -
ent-child relation of nodes is also often important for their functionality. As an
example, in Unity to create a dynamic and colliding physics object you would at-
tach both a Rigidbody component and a Collider component to a GameObject.
In Godot you would create a similar object by creating a Rigidbody node and a
Collision Shape node as a child of the Rigidbody to enable collisions. (Godot
Docs 2021j.)

The node and scene system in Godot allows for much flexibility and the main
hierarchy of all nodes while the game is running, known as the scene tree in
Godot, can be constantly changing. The Godot Editor serves essentially as an
editor to edit scene files and all the properties of the nodes contained within
them. The default scene format in Godot, the TSCN format, is also meant to be
human-readable and friendly to version-control systems (Godot Docs 2021l).
(Godot Docs 2021j.)

While using Godot’s scene system is the normal way of creating applications, it
can be bypassed, partly or as a whole, by using Godot’s low-level APIs known
as Servers. The VisualServer handles graphics, PhysicsServer and Physics2D-
Server handle physics and the AudioServer handles audio. Using Servers can
be a way of having more control over the game architecture, without having to
use nodes. It can also be helpful for optimizing for cases where the additional
overhead of nodes and scenes would prove troublesome. (Godot Docs 2022e.)
18

3.3.3 Graphics

The current stable version of Godot Engine has two renderers, a GLES3 ren-
derer meant for higher-end platforms, like desktop, and a GLES2 one for lower-
end platforms, like web and mobile. All features are available on the GLES3
version, but some are missing in GLES2 for compatibility and performance
reasons. (Godot Docs 2022d.)

For 3D graphics, Godot Engine features a physically based rendering pipeline
for 3D models based on the physically based rendering theory work by Disney.
Materials support realistic parameters like roughness and metallic, and effects
such as normal mapping and subsurface scattering. Godot also supports vari-
ous forms of transparency in materials and screen-space effects like refractions
and reflections. (Godot Docs 2022d.)

The common types of 3D lights, omnidirectional, directional and spot, are avail-
able in Godot. All lights can optionally cast shadows, done using shadow map-
ping. Godot supports near real-time indirect lighting using what are called GI
probes (GI standing for global illumination). For realistic lighting on lower-end
devices, high quality baked light-mapping textures can be generated. Godot
also features reflection probes to more accurately capture environmental reflec-
tions. (Godot Docs 2022d.)

For 2D graphics, Godot Engine features rendering of sprites and textured poly -
gons. Godot also has simple 2D lighting features with normal maps for sprites
and shadow casting. For user-interfaces, there is support for sliced images and
font rendering. All of the built-in shading features in Godot can be extended us-
ing Godot’s own shading language that is very similar to GLSL, or by using the
node-based visual shader editor to create custom shaders. (Godot Docs
2022d.)
19

3.3.4 Physics

Godot Engine has separate physics engines for both 2D and 3D uses. Both can
be used for typical rigid body physics and offer easy-to-use physics features for
controllable characters with the kinematic body nodes. There is support for trig-
gers with the 2D and 3D area nodes, that can additionally locally override phys-
ics parameters, and ray-casting features for both physics engines. (Godot Docs
2022d.)

There is support in the 3D physics engine for soft body simulation, that can be
used for cloth animation. There are features for various joints in 2D and 3D to
create realistic mechanical animation and ragdoll simulations. Godot also in-
cludes a vehicle physics controller for creating simplified car physics. (Godot
Docs 2022d.)

As for the performance of physics in Godot Engine, the YouTube channel Mean
Gene Hacks (2021) posted some videos showing testing related to both 2D and
3D physics performance in Godot versus Unity. For 3D, it seems that Godot
lags significantly behind in terms of performance of a large number of physics
objects. Perhaps surprisingly, considering the 3D results, the 2D performance in
Godot was comparable to that of Unity. (Mean Gene Hacks 2021.)

3.3.5 Scripting

In contrast to both Unity and Unreal, the main scripting language of Godot is its
domain-specific GDScript language. The decision to go with a custom scripting
language was made based on various needs and goals that the project had,
such as the focus on reducing complexity for both the user and the maintainers
of the codebase. A custom scripting language allowed for a tighter integration in
the engine, by for example allowing rich code completion with the built-in script
editor. (Godot Docs 2022b.)

GDScript is a dynamic language similar in its syntax to Python. GDScript offers
optional typing of variables and includes built-in types for game development re-
20

lated data, like multi-dimensional vectors, colors and matrices. GDScript uses
reference counting to manage memory, so no garbage collector exists like in
C#. Each GDScript file is its own unnamed class by default and can optionally
be named. Classes can inherit from built-in classes and other class files, but
multiple inheritance is not allowed. (Godot Docs 2022b.)

The important built-in callback methods used in Godot are the Node class’
“_ready” and “_process” methods (Godot API 2022a), similar to the “Start” and
“Update” methods in Unity’s MonoBehaviours (Unity API 2022a). The first one is
called on node initialization, the second one is called every engine frame. Other
callbacks also exist for things like handling inputs and physics synchronised
processing. Godot’s official documentation includes a class reference that lists
all classes, their methods and properties.

Nodes can communicate between each other using Godot’s signal system.
Many built-in nodes include signals, like user-interface elements and physics
objects, that can be connected to the scripts on nodes to call methods. For ex -
ample, the base class for all buttons includes a “pressed” signal that can be
connected to a script to call a method when that button receives an input from
the user. Custom signals can also be created. (Godot Docs 2022b.)

GDScript offers a simple way of adding coroutines using the “yield” keyword. Its
use is similar to the “await” keyword in C#. Yielding functions in Godot is power-
ful, especially when combined with the use of signals. Yield statements can wait
for a signal to emit before continuing, for example from a timer timeout or an an-
imation finishing. (Godot Docs 2022b.)

In addition to GDScript, Godot fully supports scripting using C# 8.0. C# support
using Mono was added to Godot 3.0 thanks to a donation from Microsoft
(Etcheverry   2017).    While   not   as     tightly   integrated   as   GDScript,
scripting with C# works mostly the same, besides the obvious language
differences, like static typing. C# is generally considered to be faster in terms of
performance than GDScript. (Godot Docs 2022a.)
21

Besides the main languages, GDScript and C#, Godot also offers support for
scripting using the engine’s native C++ language using a system called GDNat-
ive. There is also a visual node-based scripting tool for a more non-programmer
friendly alternative. All of the scripting languages can also be combined in pro-
jects so that, for example, performance critical scripts can be written in C# or
C++ and more designer friendly scripts can use GDScript or even visual scripts.
(Godot Docs 2022d.)

3.3.6 Animations

Godot has powerful animation features. Almost any parameter can be anim-
ated, method calls can be made from animations and audio clips can be played.
Animation easing, interpolation, looping and timings can be adjusted, along with
all other animation properties, from the dedicated animation editor panel. There
is also support for onion skinning. (Godot Docs 2022c.)

For more advanced transitioning of animations, a flexible node-based animation
tree is available. This is especially useful for animated 3D characters and can
contain nodes for state machines, blend spaces and simple animation blending.
Godot offers other advanced animation features, like inverse kinematics and
root motion. (Godot Docs 2021m.)

For quickly animating properties from code, Godot offers the tween node. Much
like animations, this node can interpolate almost any parameter. You can create
multiple simultaneous tweens with custom timings and easing curves. You can
even interpolate method calls. Tweens make it easy to quickly animate things,
like user interface transitions, or even game mechanics such as tile-based
movement. (Godot API 2022c.)

3.3.7 Audio

Godot Engine’s audio features consist of an audio bus system and nodes that
stream audio. There are separate nodes for 2D, 3D and non-positioned audio.
22

The nodes can route the audio they output to any available audio bus, which
have individual volume controls. Multiple buses can be added, each bus having
built-in effects available for processing the audio. Audio can be routed between
multiple audio buses before reaching the master output bus. (Godot Docs
2021a.)

The audio streaming nodes can play various types of streams, even procedural
audio with tone generators. The pitch, volume, distance, attenuation and some
other 3D-specific parameters can be adjusted based on the type of node. Phys-
ics area nodes can optionally override the audio output of the audio streaming
nodes that overlap their shape. This can be combined with a special audio bus
layout for reverb simulation. There is also support for an automatic Doppler ef-
fect, which will adjust the pitch of a 3D audio source based on tracking its velo-
city over time. (Godot Docs 2021b.)

3.3.8 Networking

Godot offers ways for doing both low-level and high-level networking. More ex-
perienced users, and those who want to have more control over the networking
in their game, can use the low level UDP and TCP protocols or the higher-level
SSL and HTTP protocols. While these protocols enable greater control over the
networking in your project, they can be difficult and time-consuming to imple-
ment. (Godot Docs 2021i.)

Godot provides a simplified high-level multiplayer API. This system can be used
to connect clients to a server and synchronise method calls and variables. The
scene tree, the core node hierarchy in Godot, also manages the networking.
The default implementation used in Godot is based on the ENet library, which
works for most platforms, but there is the option of using the WebSocket and
WebRTC standards for networking when exporting to the HTML5/WebAssembly
platform. (Godot Docs 2021i.)
23

3.3.9 Asset workflow

Godot Engine supports a variety of different image, texture, audio, video, 3D
and data file types. Files are automatically imported when added to the project
folder, based on some default import parameters. These import parameters can
be changed from the dedicated import panel. (Godot Docs 2021c.)

For images and textures, Godot supports many common image formats like
BMP, JPEG and PNG. There is also support for OpenEXR and Radiance HDR
files with high-dynamic-range, useful for panorama sky backgrounds. Textures
can manually be marked in the import panel to be used as normal maps, or
automatically by using them as a normal map in a material. Godot also has op-
tions for different methods of lossy and lossless image compression. (Godot
Docs 2021c.)

Godot Engine supports the WAV, Ogg Vorbis and MP3 formats for audio files.
Support for the MP3 format was added since the patents related to it have ex-
pired (GitHub 2019). Each of these formats can be used for any purpose, sound
effects and music for example, but come with their inherit costs and benefits in
terms of performance and file size. (Godot Docs 2021c.)

The 3D scene and model import workflow in Godot is recommended to be done
using the open glTF 2.0 file format. The older open COLLADA format is also
supported. Since Godot Engine is an open-source project, it heavily embraces
open standards and prioritizes open-source workflows with other open tools,
namely Blender in this case. For a better workflow with proprietary 3D tools like
Autodesk’s 3ds Max and Maya, Autodesk’s FBX format is supported. Godot’s
FBX importer saw numerous improvements thanks to the virtual social platform
developer IMVU sponsoring work related to it (MacPherson 2020). There is also
an experimental native Godot scene file exporter for Blender available. (Godot
Docs 2021c.)

There are many ways Godot can manage a 3D scene file, to combine materials,
meshes and animations, or separate them to different files. Import settings re-
lated to mesh formats, animations and lightmap baking can be adjusted. A com -
24

mon workflow is to take the imported scene file and create an inherited Godot
scene file, which can then be modified further. Even when updating the original
scene file, most of the changes in the inherited version can be kept. Godot can
also detect some import hints written in object names of an imported 3D scene
file. These hints can be used to automatically generate collision shapes for ex-
ample. (Godot Docs 2021c.)

3.3.10 Platform support

The Godot Engine editor runs on and can export games to the major desktop
platforms, Windows, macOS and Linux. A web version of the editor is available,
and projects can be exported to HTML5. Godot supports exporting mobile-tar-
geted projects to Android and iOS. Exporting to Universal Windows Platform is
also supported. (Godot Docs 2021f.)

Godot offers a dedicated export panel to configure your project export settings
for each platform. Separate export templates have to be downloaded for each
platform and engine version before exporting. Godot configures the exported
project for each platform and stores the assets into a single package file. The
package file system can also be used to create patches and downloadable con-
tent for your exported projects. (Godot Docs 2021f.)

Exporting Godot Engine projects to console platforms is a somewhat complic-
ated issue. Godot does not provide a direct way of exporting to platforms like
Xbox, PlayStation and Nintendo Switch. Since Godot is an open-source project,
it can’t legally contain console specific code that would normally be covered by
a non-disclosure agreement. There does exist a way of releasing your Godot
Engine game on consoles through third-party companies offering porting and
publishing services, or by doing the porting yourself. (Godot Docs 2021d.)
25

3.4 Community

Godot Engine is a popular open-source project and has a considerable online
community surrounding it. In the age of social media, different platforms host
forums related to shared areas of interest, including software. The Godot En-
gine project has many of these communities surrounding it. These are platforms
where people discuss and share their work, experiences and development re-
lated to Godot. (Godot Engine 2022b.)

The Godot Engine project has its main website (godotengine.org), that hosts an
introduction to Godot, a news section, links to community pages and resources
and the official downloads for Godot. Godot Engine’s source code is hosted on
GitHub and the repository is very active with over 48,000 stars, as of writing, the
most of any repository with the tag of “gamedev”. Due to the large amount of
activity on the main GitHub page, Godot uses a separate repository for improve-
ment proposals. (GitHub 2022.)

Godot Engine has an active Discord server with over 44,000 members, and a
Reddit page with over 85,000 readers. There are some successful content cre-
ators, like GDQuest who have a successful YouTube channel with over 175,000
subscribers, focusing on Godot and game development related content.
GDQuest has created a lot of free resources related to open-source game de-
velopment and also ran multiple successful Kickstarter campaigns. GDQuest
even used funds raised from a successful campaign to hire two developers to
work on Godot improvements (Lovato 2021). (Godot Engine 2022b.)

There are several Godot related game jams organized periodically. There is the
Go Godot Jam (2022), which is a month-long event with a game jam and live
events with tutorials, interviews and other content. The latest Go Godot Jam
saw over a hundred entries submitted. There is also the monthly Godot Wild
Jam (2022), which I have personally taken part in twice, reaching its 44th itera-
tion. A Godot related conference, GodotCon has also been arranged a few
times, with the last one taking place online in July of 2021 (Cislaghi 2021).
26

The vast majority of community interactions surrounding Godot are very posit-
ive. From my own experience, the Godot community is very open, inclusive and
welcoming. However, as with any online community, a set of standards are im-
portant to adopt and maintain to ensure the long-term health of the community
and its direction. To this end, the Godot Engine project adopted a Code of Con-
duct applying to all platforms, users and contributors in 2019 (Verschelde 2019).
27

4 GAME PROJECT

This section will describe the practical project that was created as a part of this
thesis work. The project is a playable game created using Godot Engine. The
game is created to highlight various features and aspects of the engine and also
serves as an example of how a full game can be structured in Godot. The goal
was to create a simple, yet complete, game that would not only show the en-
gine’s capabilities, but also help illustrate workflows and common practices for
working with Godot. The project took approximately three months to complete,
although not worked on full-time for that whole period.

The game was created mostly using Godot Engine version 3.4.2. At the time of
completion, the maintenance release, Godot 3.4.3 had already been released.
The project is freely downloadable on the itch.io indie game hosting service and
the full source code and project files are available on GitHub (Appendix 1). All
scripts are heavily commented for reference and educational purposes.

4.1 Island Assault

Island Assault is a simple top-down shoot ‘em up action game created using
Godot Engine (Picture 2). The game is inspired by the classic MS-DOS game
Raptor: Call of the Shadows released by Cygnus Studios in 1994. The game
has a single level, five enemy types including a boss enemy, upgrades for the
player ship and a checkpoint system. The goal is to complete the level by de-
feating the boss while aiming for a high score.

The code of Island Assault is completely written in Godot Engine’s own scripting
language, GDScript. While other supported language, like C#, offer more ad-
vanced language features, the tight integration and simplicity of GDScript make
it an appealing choice for small projects. I am personally more familiar working
with GDScript and I also wanted to showcase its features as a part of this pro-
ject, making it the obvious choice. All of the script files are available, along with
other project files in the repository linked in appendix 1.
28

Island Assault is minimalistic and stylized in graphical appearance. The visuals
take advantage of flat colors, thick outlines and subtle gradients to portray depth
and lighting. Almost all graphical assets were created as vector graphics using
the illustration application Affinity Designer. Appendix 2 shows the main vector
document used for graphics. The game has electronic, retro inspired music and
sound effects created using the digital audio workstation Reaper.

The game is controllable using the keyboard or a game controller, like an Xbox
Wireless Controller. The game supports various display resolutions running in a
window or full screen. Sound and music audio levels are independently ad-
justable. The game has a locally saved high score list, and user settings are
saved to a configuration file. Although it is an important accessibility feature,
controls are currently not configurable due to a lack of time to implement the op-
tions to do so.

PICTURE 2. A screenshot of the Island Assault main menu.

4.2 Structure

Games created using Godot run in a single hierarchy of objects or nodes called
the scene tree. This hierarchical structure is a core part of Godot and structuring
29

both the nodes in your game and the files in your project following this pattern
can be helpful. While Godot does not force you to work in any particular pattern,
it embraces object-oriented design, especially inheritance, unlike the highly
compositional approach of engines like Unity and Unreal (Godot Docs 2021h).

To follow the practices outlined above, the structure of the main scene tree and
the project files are somewhat similar. You can see this in a side-by-side com-
parison of the main scene tree of the game while running, and the file system
view of the project files (Picture 3). While these don’t match exactly, they do of-
fer some guidance in what scene and script files should go where. Generally,
when developing in Godot, you want to store the script file along with the scene
file that utilizes it. It is good to also store assets used by the scenes, such as im-
ages and audio, in the same place as the scene.

PICTURE 3. Screenshots of Island Assault’s scene tree view on the left and the
project files on the right. Note the similar file and node names.
30

This way of structuring your game project is not how projects are often struc-
tured in an engine like Unity. Unity provides a default structure for assets where
things like materials, scenes and scripts are all in separate folder hierarchies.
This can make more sense for a compositional design pattern, where compon-
ents in Unity’s GameObjects can be attached to a number of different types of
objects. Scripts in Godot are generally only attached to one or one instance
type of node. The main game node only consists of one scene file and one
script file in Island Assault for example. You might think of a Unity file system as
more of a library with sections for different types and a Godot file system as a
family tree where the position in the tree is a more identifying point.

In the Godot project settings, you have to choose the main scene that the game
starts with. In Island Assault, this main scene contains the game scene and
main menu scene. At the start, the main scene’s script starts up the main menu
and the game is designed not to start until called to do so. This means that the
main menu and the game are both loaded in memory on startup. This is fine for
a simple game like Island Assault that does not use large asset files or con -
sume much memory. In a more complex game, it would be better to do this only
after the menu is navigated and a loading screen can display.

In Godot, you can change the scene that is running with methods in the
SceneTree class, but it is not necessary (Godot API 2022b). In Island Assault,
the scene is never changed, only child nodes are instantiated and removed as
necessary. This is a similar approach as you could achieve in Unity with a multi-
scene workflow (Unity Docs 2022d). In Godot, adding and removing child nodes
is very simple and performant, so this workflow is commonly used.

This section covered some basic information about how projects in Godot are
structured. More specific examples of the design, like looking at the player con-
troller in Island Assault, will be shown next. For a more detailed view of the pro -
ject files and the structure of the Island Assault Godot project, refer to the links
provided in appendix 1.
31

4.3 Player controller

The player-controlled ship in Island Assault uses a KinematicBody2D node as
its base. This node, along with its 3D counterpart, is meant to be used for user-
controlled physics bodies like player characters. It has similar functionality as
Unity’s Character Controller component and can be moved with code or by an -
imations. KinematicBody2D has a few helpful methods available for moving it,
of which Island Assault uses the “move_and_slide” method. This moves the
body while letting it slide along other bodies, instead of just stopping.

The player scene consists of three main parts. The main player node and script
handles player inputs and moving the player ship. There is a separate node that
manages the visual part of the player, controlling sprites and shaders. This is
because the player ship in Island Assault is composed of multiple sprites and
utilizes shader and lighting effects that need a decent amount of code to func-
tion. The last main part of the player scene is the gun node and script. The
player’s gun is upgradable and can shoot in different styles, making the gun lo -
gic complex enough to warrant its own script.

Interestingly, this somewhat compositional way of using multiple nodes for the
player is reminiscent of a component approach. You can indeed make your own
“components” in Godot and work with them in much the same way as you would
in Unity. At least occasionally, this pattern can be helpful to split up code and
nodes so that one does not become too complex. Godot’s observer pattern-
based signal system, as discussed earlier in the introductory section, is helpful
for managing communication between nodes.

Handling user input is perhaps the most basic and important part of any game’s
programming. To give an idea of how input can be handled in Godot, the Island
Assault player script shows some basic ways of doing this (Figure 1). There is
logic in both the process and physics process methods of the player node. In
the process method, input is read using the Input singleton class. In the physics
process method, this input information is used to move the player using the
“move_and_slide” method provided by KinematicBody2D. Moving kinematic
bodies should always be done in the physics-synchronised process method.
32

        In Godot, each node can have input specific callback methods that handle input
        events. Since the player’s inputs should be checked every frame during game-
        play anyway, Island Assault just reads inputs in the process method. With the
        input callback events, once user gives the Godot game input, it is propagated
        through the scene tree hierarchy until it is either handled by some node or
        reaches the end of the tree. For more information on how event-based inputs
        work, refer to the Godot documentation page on InputEvents (Godot Docs
        2021n).

# The process method handles reading the player input.
func _process(delta):
 # Reading the input axex to form the input Vector2.
 input_move_vector = Vector2(Input.get_axis("left", "right"), Input.get_axis("up", "down"))
 # Clamping the vector length to avoid diagonal movement being faster.
 input_move_vector = input_move_vector.clamped(1.0);
 # Setting the current move vector by using the move toward method.
 # The move toward method is used along with the delta and acceleration to
 # give smooth yet responsive movement.
 current_move_vector = current_move_vector.move_toward(input_move_vector, delta * acceleration)
 # If controllable, also read firing input.
 if Input.is_action_pressed("fire") and controllable:
  # Fire the gun, even every frame. Gun handles the fire rate.
  player_gun.fire()
 if controllable:
  # If controllable, also give the visual node the movement information
  # used for effects.
  player_visual.reference_vector = current_move_vector

# Physics process handles actually moving the KinematicBody2D node.
func _physics_process(_delta):
 # If controllable, use the move and slide method to move using the move
 # vector multiplied by the speed.
 if controllable:
  move_and_slide(current_move_vector * speed)

        FIGURE 1. Input handling section of the player.gd script file.

        Continuing with some more details of this section of the player script (Figure 1).
        There are some additional checks for whether the player is controllable cur-
        rently or not. Having a Boolean variable for tracking player controllability is a
        handy way of dealing with moments when the player is on screen, but not inter-
        acting, like cutscenes. The player process method also uses the child player
        gun and player visual nodes, the references for which are retrieved earlier in the
        ready method.
33

The player script manages player health, speed and lives (Figure 2). These are
stored as variables that change based on gameplay conditions. The variables
use the “export” keyword to make them editable in the Godot editor’s inspector
window. GDScript supports setter and getter functions for variables, defined
with the “setget” keyword. Setter functions are used for each of these player
status variables.

There are upgrades to replenish health and lives and an upgrade to increase
movement speed. The setter function checks if an upgrade would bring the
value to above the maximum, making the upgrade unnecessary. These extra
upgrades give a score bonus reward via a signal. The setter function also emits
signals each time the values changes. This is used to keep the interface up-
dated when values change. The values are also clamped accordingly.

 # Exported variable for the health with a setget method.
 export var health := FULL_HEALTH setget set_health
 func set_health(value: int):
     # If trying to set health to above full health, reward bonus points.
     if value > FULL_HEALTH:
          emit_signal("bonus_upgrade")
     # Limit health amount.
     health = int(min(value, FULL_HEALTH))
     # Emit signal to update gui.
     emit_signal("health_updated", health)
 # Exported variable for the speed with a setget method.
 export var speed := DEFAULT_SPEED setget set_speed
 func set_speed(value: float):
     # If trying to set the speed to above maximum, reward bonus points.
     if value > MAX_SPEED:
          emit_signal("bonus_upgrade")
     # Limit speed value.
     speed = min(value, MAX_SPEED)
 # Exported variable for the lives with a setget method.
 export var lives: int = FULL_LIVES setget set_lives
 func set_lives(value: int):
     # If trying to set lives to above full amount, reward bonus points.
     if value > FULL_LIVES:
          emit_signal("bonus_upgrade")
     # Limit lives amount.
     lives = int(min(value, FULL_LIVES))
     # Emit signal to update gui.
     emit_signal("lives_updated", lives)

FIGURE 2. Status variables section of the player.gd script file.

Along with the player’s health, speed and lives, the player’s gun is also upgrad-
able with collectible powerups. These upgrades are implemented using an in-
You can also read