Explore Free Godot 4 Tutorials – GameDev Academy https://gamedevacademy.org Tutorials on Game Development, Unity, Phaser and HTML5 Tue, 11 Apr 2023 08:31:27 +0000 en-US hourly 1 https://wordpress.org/?v=6.1.1 https://gamedevacademy.org/wp-content/uploads/2015/09/cropped-GDA_logofinal_2015-h70-32x32.png Explore Free Godot 4 Tutorials – GameDev Academy https://gamedevacademy.org 32 32 Unreal vs Godot – Should You Use One or the Other for Games? https://gamedevacademy.org/unreal-vs-godot/ Tue, 11 Apr 2023 08:31:27 +0000 https://gamedevacademy.org/?p=20276 Read more]]> Fact: your favorite video games are developed using game engines.

From well-known engines like Unity to lesser-known engines like Pico-8, game engines are an important facet of game development. They dictate the entire manner in which you go about it, and unsurprisingly, each engine has its own unique features. As you can imagine, picking the “right” game engine is very important when starting a game project.

In this article, we’re going to take a look at two very popular engines: Unreal Engine and Godot. We’ll be exploring both in terms of things such as versatility and popularity, and give you all the need-to-know info to decide which engine is the best for your personal situation.

Let’s get going!

What is a game engine?

Before we get too deep into this discussion topic, we do want to discuss a bit about what game engines actually are. For those just starting out, this is a good concept to wrap your mind around so you can interact with game dev jargon successfully.

A game engine, sometimes known as a game framework or game architecture, is a software development platform including settings that optimize and improve the experience of developing video games.

Game engines can facilitate the development of 2D and 3D games compatible with different import formats, allow developers to simulate physics, integrate AI, and use a sound engine to produce sounds.

Without game engines, the game development would be a lot more tedious. Instead of just working with your actual game mechanics or doing things like making cutscenes, you’d be stuck writing every backend structure. This includes things such as telling the computer how to even render your graphics. Making an engine is no small feat, and there’s a reason many engines are in-house and proprietary for AAA studios.

As such, game engines are one of the most important tools for development as they reduce the time and effort it takes to make a successful game (which believe us, still takes many, many hours).

BUILD YOUR OWN GAMES

Get 250+ coding courses for

$1

AVAILABLE FOR A LIMITED TIME ONLY

Versatility

As a developer, you’re free to make any type of game you wish – like 2D, 3D, AR, VR, mobile, multiplayer, and more. The game engine you choose should support the game type you wish to create, and Unreal Engine and Godot both support a wide range of games.

These include:

  • 2D. While Unreal Engine is best known for making 3D games, it can also be used to make 2D platformer games like Snake or sprite-based games. That said, Unreal Engine is definitely not the best for 2D, and can’t really be recommended. In the opposite corner, new updates to Godot 4 have significantly improved its ability to make powerful 2D games, with features such as 2D lighting, 2D light and shadow support, 2D materials, and 2D masking and clipping. Plus, Godot has a dedicated 2D engine, making it more performant in this arena (especially when it comes to physics).
  • 3D.Unreal Engine is well known for its powerful 3D game development software, with features such as pipeline integration, world-building, and simulation & effects. In comparison, while Godot does offer 3D and is powerful (with Godot 4 adding updates in this area as well), it simply can’t compare to the powerhouse that is Unreal Engine.
  • Augmented Reality (AR). There are currently no AR capabilities for Godot, whereas Unreal Engine has a high-level AR interface with features including face tracking, people occlusion, motion capture, augmented faces, and more.
  • Virtual Reality (VR). While Godot’s VR software isn’t yet up to par because of licensing issues, Unreal Engine’s VR framework is vast, allowing developers to build highly powered virtual reality apps. Unreal Engine is compatible with Oculus VR, SteamVR, Windows Mixed Reality, Samsung Gear VR, and Google VR.
  • Mobile. Both Godot and Unreal Engine have mobile capabilities. However, Unreal Engine has far more features and is compatible with Android and iOS game development.
  • Multiplayer. Godot 4 has made significant improvements to make complex multiplayer games easier for developers. The update includes improvements in scene replications and state & RSET updates. As for Unreal Engine, it also has lots of multiplayer features that are well-established, well-documented, and fairly stable.

Unreal vs Godot - Should You Use One or the Other for Games?

Coding

As a general rule of thumb, game engines tend to have one or two languages they specialize in. As such, picking the right game engine can often be tied to picking your preferred programming language as well.

In the case of Unreal Engine, there are two major choices – C++ and Blueprints Visual Scripting.

C++ is one of the most universally used and powerful programming languages out there – so you can’t go wrong with learning C++. However, and that’s a big however, it is also one of the single most difficult languages and not particularly designed for readability. Additionally, in recent years, many indie developers have moved away from C++ due to facing issues coding with it.

On the other hand, the Blueprints Visual Scripting system in Unreal is immensely powerful. With it, there’s no need to know how to code – instead you just drag and drop your functionality right onto the canvas to create logic. Thus, it’s a fantastic option for beginners who’d rather not learn tedious syntax they’ll never remember.

As for Godot, there are also two main languages here, C# and GDScript.

C# is similar to C++… except that is much more beginner-friendly. C# was designed to be a somewhat balanced language, coming with the readability of higher-level languages but still having some benefits that come only with low-level languages.

That said, Godot’s main driving force is GDScript – a scripting language developed specifically for the engine. This language, which resembles Python in some respects, is made to be easy to read and easy to use specifically for game development. That said, GDScript can’t really be used outside Godot, so learning it doesn’t benefit you if you want to go onto other platforms.

Industry Presence & Popularity

Professional game developers understand what makes a good game engine, and their use of such software can be a determining factor used to judge the competence of a software. Both Unreal Engine and Godot have made a splash in the video game industry, and both are capable of developing powerful games.

Unreal Engine is popular thanks to its high-fidelity graphics, ease of access, modularity, and just immensely powerful rendering capabilities. It’s used by both novice and expert developers, and has been used to make some of the most popular games on the market including Fortnite, Batman: Arkham City, The Matrix Awakens, and Alien: Fireteam Elite.

Likewise, Unreal Engine has been widely used even outside of games – especially when it comes to things such as film where its graphics can’t often be beaten by other software.

Godot, on the other hand, is a much younger engine. And, simply due to this youth, it’s not as established in the industry. That said – and particularly for indie developers – Godot has been quickly on the rise. Godot is also open source, which has attracted a lot of developers given the popularity of open source in general.

Regardless of its age, though, Godot has been used to create some popular games, including Lumencraft, Project Heartbeat, and Dashpong.

Unreal vs Godot - Should You Use One or the Other for Games?

Community

Game developers need a supportive community network when making a game, normally seeking support from other professionals, subreddits, YouTube channels, and more. Both Unreal and Godot have online communities offering resources for online users.

  • As an open-source project, Godot has attracted a vast community. From subreddits to a Discord chat, there’s a place for everyone in the Godot community to help each other and even contribute to the engine’s development.
  • Unreal Engine has a subreddit with over 200,000 Unreal Developers, giving information on everything you’ll ever need to know about Unreal. They also have a YouTube channel with regular updates about the game engine, tutorials, reviews, and more.
  • If you’re interested in attending in-person and online events, Unreal Engine hosts events throughout the year, designed to help fellow Unreal developers connect and share their innovations.
  • Godot also hosts various in-person and online events every year. For example, at Godot @ GDC 2023 they showcased their new games made using the Godot 4 game engine.

Both Unreal Engine and Godot also have a marketplace for assets like 3D models, textures, and systems that can be used on the engine, known as asset stores. These are largely driven by the community as well, so both have a lot to offer here.

Cost

If you’re an indie, then there’s another huge factor to consider: how much is all this going to cost you? That’s where you’re fortunate.

Unreal Engine has three licenses. With the standard license, it’s completely free to use the engine. The only catch is that once you make $1 million in revenue, you need to pay a 5% royalty fee. That said, if you do need more features, such as more developer support, Unreal also offers the Enterprise License which costs $1,500 per seat per year, or their Custom License which is quoted based on your needs.

Godot, on the other hand, is completely free. As an open-source project, there are no secret strings attached. It’s just free and will remain free far into the foreseeable future.

Tutorials & Courses

We imagine at this point, you’ve been swayed in one direction or another. So we’re going to kill two birds with one stone. First, we’re going to get you started with learning resources for both so you can jump right in. Second, we’ll give you a chance to see both engines in action by the same links. Trying both engines is the best way to figure out which one is for you!

Unreal

  • Unreal Game Development Mini-Degree, Zenva. In Zenva’s curriculum, you can start off with zero knowledge and learn Unreal Engine 5 from the ground up. You’ll master everything from the basics of the engine itself, to making portfolio-worthy projects such as FPS games, RPGs, walking simulators, and more!
  • Unreal Engine 101 – 3D Game Creation, Zenva. With this free course, you’ll learn how to get started with Unreal Engine by learning the fundamentals of manipulating game objects, as well as exploring the basics of lighting and physics and how you can incorporate these elements into gaming projects.
  • Unreal Engine 5 Beginner Tutorial – UE5 Starter Course, Unreal Sensei. This free video tutorial goes over everything needed to get started with Unreal Engine, focusing on features including nanite and lumen. This course will teach you installing Unreal, navigating its 3D viewport, creating materials and worlds, sculpting landscapes and foliage, programming using Blueprints, and more.
  • Unreal Engine Beginner Tutorial: Building Your First Game, Devslopes. This video tutorial gives you the mechanisms to build a simple game using Unreal, with the Blueprint Visual Scripting system. You’ll learn the fundamentals, including the Unreal editor itself, simple AI, events, spawning objects and effects, and the process of building games.

Godot

  • Godot 4 Game Development Mini-Degree, Zenva. This curriculum is all about giving you all the fundamentals you need to get going with Godot 4. You’ll start with the fundamentals, and then work your way to building real projects such as RTS games or RPG battle systems.
  • Godot 101 – Game Engine Foundations, Zenva. The Godot 101 course aims to teach the fundamentals of working with Godot 4, including information on how to work with Godot 4’s nodes and scenes architecture. You’ll also learn a tiny bit about getting started with GDScript.
  • Godot 4 Crash Course for Beginners – GameDev 2D Top Down Tutorial, Chris’ Tutorials. This guide teaches developers everything there is to know about the changes to Godot 4, including the tilemap tools, moving characters, and the changes to GDscript syntax.
  • Create Your First Complete 3D Game with Godot, GDQuest. This course is designed for individuals with prior coding knowledge, and takes users through the coding process from start to finish – at the end, you’ll have made your very first 3D game! Learn how to spawn monsters, make your character jump and squash, the ins and outs of animation, and much more.
  • Build a Top-Down 2D GODOT RPG in 20 Minutes, Andrew Hoffman. This video tutorial will teach you how to build a top-down 2D GODOT RPG game in just 20 minutes, including information on coding collisions, character movement, tilemaps, proper scripting, and more.

Unreal vs Godot - Should You Use One or the Other for Games?

Conclusion: Unreal vs Godot – which is better?

Let’s now turn back to our original question – should you use Unreal for your games or Godot?

The answer here is complex, and there is no one definite “right” answer. It all depends on you and your game projects. For example, if you’re making a VR game, then of course Unreal is going to be the better choice of tool. However, Godot is going to do much, much better with a 2D game, so for that Godot is the superior option.

Then again, perhaps you want the benefit of visual scripting for your 2D game, which means Unreal. Or, perhaps you just like Godot’s multiplayer features better so pick Godot for your 3D game anyway. It all comes down to personal taste and what you’re comfortable working with.

That said, it also doesn’t matter to some degree. Both engines offer a ton of resources to use, including tons of courses through which to learn and explore things.

Still, we hope this article has helped you become more informed, and we can’t wait to see the games you create with one or both engines!

BUILD GAMES

FINAL DAYS: Unlock 250+ coding courses, guided learning paths, help from expert mentors, and more.

]]>
Unity vs Godot – Choosing the Right Game Engine for You https://gamedevacademy.org/unity-vs-godot/ Tue, 11 Apr 2023 05:44:19 +0000 https://gamedevacademy.org/?p=20270 Read more]]> Most modern video games are developed using a game engine – which allows developers to focus on building their game rather than the tedious backend systems that run it. This makes finding a game engine that works for your project essential, since you’ll be spending quite a bit of time working with it.

With a ton of game engines available, though, how do you pick?

In this article, we’ll be exploring Unity and Godot – two powerful and popular game engines used for 2D & 3D games.

When looking for a game engine, it’s essential to assess its versatility, power, and popularity within the industry. We’ll be taking a look at several factors – such as their versatility and industry presence, and also get you learning resources so you can dive into the engine of your choice.

If you’re ready to pick your game engine, let’s get started!

What is a game engine?

Before we get started, for those new to game development, we first want to talk a bit about what a game engine is. In this way, the reason why a game engine can help you is more clear (and you can temper your ambitions by thinking you need to make your own).

A game engine, sometimes referred to as game architecture or game framework, is a software development environment complete with settings and configurations that improve and optimize the development of video games, integrating with various programming languages.

Game engines can include 2D and/or 3D graphics rendering engines that are compatible with different import formats. They will also often include a physics engine that simulates real-life properties, AI that is designed to respond to the player’s actions, and a sound engine that controls the sound effects within the game.

As stated previously, game engines are primarily designed to make your life easier. Without them, not only would you have to program your game mechanics, but instructions for your computer on how to access and play sounds, how to display your graphics, and so on. This quickly becomes a huge tedium of work – which is often why a big deal is made whenever a AAA company makes a new in-house engine; they really change everything about how a game runs in general.

To summarize, game engines are simply a powerful tool for your game development arsenal. They make sure you aren’t stuck programming every single tiny detail (unless you want to), and get to have fun with the stuff most players actually care about.

BUILD YOUR OWN GAMES

Get 250+ coding courses for

$1

AVAILABLE FOR A LIMITED TIME ONLY

Versatility

There are a variety of different types of games that you can choose to develop, from 2D to virtual reality. A good game engine will support coders in creating a wide range of games, and both Unity and Godot do this. Here are the different types of games you can choose to develop and how Unity and Godot can support your development journey:

  • 2D. Both engines are more than capable of developing 2D games, with Unity giving its users a broad tool set. However, new updates to Godot 4 have significantly improved its ability to create 2D games, including 2D lighting, 2D materials, 2D light & shadow support, and 2D masking and clipping. It’s also worth noting that Godot offers an actual dedicated 2D engine, while Unity still technically uses its 3D engine to render 2D games. This has some performance implications for more complicated projects.
  • 3D. While Godot is capable of making 3D games, it isn’t as powerful and doesn’t have as many features as Unity. In terms of graphic fidelity, Unity is therefore the superior choice. That said, Unity is consequently the heavier-duty engine and may not work as well on older computers as Godot.
  • Augmented Reality (AR). There are currently no AR capabilities for Godot, whereas Unity has an established AR interface and has been contributing to AR output for years.
  • Virtual Reality (VR). Unity is an excellent game engine in terms of VR, as the plugins used are versatile and are able to integrate into the XR infrastructure. While VR capabilities have improved with Godot 4, export doesn’t yet work for meta quests due to licensing issues. For now, Unity is still the superior choice.
  • Mobile. Both Godot and Unity have mobile capabilities. That said, Unity perhaps offers a few more tools when it comes to the actual development process, such as the Device Simulator.
  • Multiplayer. Both platforms have multiplayer features to offer. The Godot 4 update in particular has massively improved the ability to make complex multiplayer games. The update includes improvements in scene replications, RSET, and state updates. As for Unity, with the recent release of the Unity Multiplayer Networking features, it’s easier than ever to develop multiplayer projects. In this area, both over a relatively good basis to work from.

Unity vs Godot - Choosing the Right Game Engine for You

Coding

The coding language you are most comfortable with will have a determining factor in what game engine you decide to use.

Unity uses C# for its scripting logic, which is generally considered a fairly well-balanced language to learn. This language offers some enhanced readability compared to C++, but has a plethora of advantages that other high-level languages can’t offer.

If coding plainly isn’t your thing, Unity also does offer a visual scripting option in its newest versions. This drag-and-drop approach means you don’t have to learn tedious C# syntax, but still get all the game logic you would with regular coding.

In comparison, while Godot is compatible with a few languages, its main language focuses are GDScript and C#. We’ve spoken about C# already for Unity, but GDScript is perhaps Godot’s “main” language. This Python-like language is made to be super easy to read and use with the Godot engine specifically (as it was developed by the Godot team). While this doesn’t have the versatility of C#, it does come with a variety of benefits for making games that much easier to make.

Industry Presence & Popularity

The game engines that professional developers are using is a good way to judge the versatility and usability of the software. Unity and Godot are both popular game engines used to create high-powered games that are popular on the market. However, each has different uses.

Unity is popular with AAA and indie developers alike because of its abundant resources. These resources include things like instant assets, online community assistance, Unity-provided tutorials, and intuitive tools for a variety of applications. It offers a lot of developer support along the way, and makes the coding process easier compared to other similar game engines. Plus, Unity offers tons of companion services (such as monetization for mobile games), making it a one-stop shop for many users.

There’s also the benefit that the Unity game engine is as powerful as it is popular. Thus, it’s been able to spread to a ton of other industries such as film, architecture, and so much more.

Popular games created using Unity include Hearthstone, Cities: Skylines, Rust, Ori and the Blind Forest, and the majority of mobile games.

In comparison, Godot is a lot younger than Unity and doesn’t have the same presence. However, Godot is quickly rising to become a major competitor. Godot also has an advantage that Unity does not in terms of development: it’s open source. As such, developers get ultimate control over the engine itself and, if push comes to shove, can make the engine do what it wants.

Despite its youth, Godot has been used to create many successful games including Kingdoms of the Dump, Cruelty Squad, Rogue State Revolution, and Dungeondraft.

Unity vs Godot - Choosing the Right Game Engine for You

Community

A strong and supportive community is very important when choosing a game engine, as you’ll be able to seek support from subreddits, YouTube channels, Discord chats, and whatever else there is to offer (plus, asset stores count here too). Luckily, both Unity and Godot have thriving communities offering help to new and seasoned developers.

  • Unity has a game developer convention held yearly called Unite. The event mostly focuses on how to use Unity with some YouTubers teaching engaging classes.
  • Unity also has a subreddit providing expert advice and knowledge, and a YouTube channel with tutorials from expert developers.
  • Godot also hosts many in-person and online events, such as Godot @ GDC 2023, where developers will showcase their new games made using Godot.
  • Godot helps its community with a subreddit, and has their own YouTube channel as well.
  • Godot is active in a ton of other channels such as Discord, Twitter, and so forth – all of which are viewable on their promoted Community page.

Both Unity and Godot also have an asset store – a marketplace for 3D models, textures, systems, etc. that can be used on the engine (with free and paid options). These assets are beneficial for developers who need extra assistance in design or coding, and are largely community supported.

This said, if we had to pick, we would note that Unity’s community is larger simply because of its longer-established reign as a popular game engine.

Cost

Last but certainly not least, let’s talk about money. What would using these game engines cost you?

Unity has a free plan – but there is a catch. In general, the rule of thumb is that once you’re earning $100K annually, you need to purchase a paid plan. That said, the majority of users will be fine with the free plan (so unless you become a AAA overnight, don’t worry too much about it).

This said, the free plan does come with fewer features, though this centers more so around developer support. For the most part, the free version still includes things like the platform itself, core features like visual scripting, and even the Unity Plastic SCM for version control (3 users and 5GB of storage).

The paid plans are as follows, though, if you’re interested:

  • Plus – $399 per year per seat
  • Pro – $2,040 per year per seat
  • Enterprise – Custom quotes depending on need

By comparison, since its open-source Godot is entirely free, with absolutely no strings attached. Of course, this does mean it doesn’t offer the same sort of premium services Unity does, but it can be less stressful to know there can’t be any shenanigans.

Unity vs Godot - Choosing the Right Game Engine for You

Tutorials & Courses

At this point, you’re probably leaning one way or another on whether to pick Unity or Godot. However, the best way to find out your preference is simply to try them out. So, to get you started (and demonstrate the quality of learning materials available), we’ve listed out some of our favorite resources.

Unity

  • Unity Game Development Mini-Degree, Zenva. With this curriculum, you’ll explore a variety of tools and features Unity has to offer. In addition, you’ll get the chance to build a ton of projects suitable for a professional portfolio. You’ll not only learn the fundamentals of game development, but make real games including RPGs, idle games, and FPS games.
  • Unity 101 – Game Development Foundations, Zenva. This free course teaches you the very basics of how Unity works and allows you to start playing with your first game objects. You’ll also learn skills needed to build your own games in any genre you choose.
  • How to Program in C#, Brackeys. This free YouTube course teaches you how to read, write, and understand C# coding from scratch, and lays the foundation for learning Unity.
  • C# Tutorial, Derek Banas. In this tutorial, you’ll learn how to install Visual Studio and Xamarin. You’ll then cover key programming knowledge including input, output, loops, data types, and more.
  • C# Basic Series, Allan Carlos Claudino Villa. In this free course, you’ll cover everything there is to know about C# to give you the knowledge needed to create games with Unity.

Godot

  • Godot 101 – Game Engine Foundations, Zenva. With Godot 101, you’ll learn the fundamentals of working with the Godot 4 editor, including understanding the core difference between Nodes and scenes. Plus, you’ll get experience working with both 2D and 3D objects!
  • Godot 4 Game Development Mini-Degree, Zenva. This comprehensive collection of courses gives you the knowledge needed to build cross-platform games using Godot. You’ll be given the tools needed to create 2D and 3D games including RTS games, platformers, and survival games.
  • Make Your First 2D Game with Godot: Player and Enemy, GDQuest. Learn to create your own games using Godot in this beginner tutorial series, hosted on YouTube. This course gives you an entire run-through on using Godot to program different game types, perfect for complete novices.
  • Make your first 2D platformer game In Just 10 Minutes, Eli Cuaycong. In this short tutorial, you’ll learn the basics to help you with your game development journey, including tile maps, world scene, and spritesheets.

Conclusion: Unity vs Godot – which is better?

Now we’ve covered the differences between Unity and Godot, let’s get back to the ultimate question – which game engine is better?

This entirely depends on what type of game you want to make, the game’s style and needs, and what kind of knowledge you’re bringing to the table.

For instance, for 3D, AR, or VR games, Unity is definitely the superior choice as it offers all the tools needed and the power to make those games work. However, on the opposite end of the spectrum, Godot is definitely the winner when it comes to 2D given it’s the dedicated and more performant rendering engine for this aspect.

Even then, there are exceptions even to the above! For example, a game like Paper Mario would probably work better with Unity, whereas a 3D game might work better with Godot in cases where you need to work with the engine’s code itself.

Regardless, both are truly great options, and you can’t go wrong with either. Plus, with plenty of courses available for both, they’re both easy to learn.

Regardless of your choice, we wish you the best of luck with your future games!

BUILD GAMES

FINAL DAYS: Unlock 250+ coding courses, guided learning paths, help from expert mentors, and more.

]]>
Complete Guide to GDScript – Godot’s Scripting Language https://gamedevacademy.org/complete-gdscript-godot-tutorial/ Thu, 06 Apr 2023 06:21:05 +0000 https://gamedevacademy.org/?p=20233 Read more]]> What is the best programming language for Godot?

With the release of Godot 4, more developers than ever before are flocking to learn this free and open-source engine. However, many come in not knowing what programming language they need to use. While C# is an option (for those familiar with Unity), GDScript is by far the go-to when it comes to scripting in Godot.

What is GDScript, though, and how does it work? In this article, we’re going to cover the fundamentals of GDScript so you can start tackling your Godot game projects with finesse.

If you’re ready, let’s get started!

BUILD YOUR OWN GAMES

Get 250+ coding courses for

$1

AVAILABLE FOR A LIMITED TIME ONLY

Introduction to GDScript

Welcome to the world of GDScript! In this section, you’ll learn what GDScript is, why you should use it, and how to set up your development environment so you can start writing code right away.

What is GDScript?

GDScript is a scripting language that was specifically designed for the game engine Godot. It’s a high-level language, which means it’s easy to read and write compared to lower-level languages like C++. And best of all, it’s designed with game development in mind, so it has features that make game development faster and easier.

Benefits of using GDScript

Here are a few reasons why GDScript is a great choice for game development:

  • It’s easy to learn and use, even for those who are new to programming
  • It’s optimized for game development, so you can write code faster and more efficiently
  • It integrates well with the Godot engine, making it a great choice for game development with Godot

Setting up the development environment

To start using GDScript, you’ll need to download and install the Godot game engine. You can download it for free from the Godot website. Once you have Godot installed, you’re ready to start writing GDScript code!

In the next section, we’ll dive into the basics of GDScript and start writing some code. Let’s get started!

2D Platformer made with Godot 4

Variables and Data Types

In this section, you’ll learn how to store and manipulate data in GDScript. You’ll learn about variables and different data types, and how to declare and initialize them.

Introduction to Variables

Variables are containers that store values in your code. Think of them like little containers that hold data that you can use and manipulate in your code. For example, you can store a player’s name in a variable so that you can use it throughout your game.

Declaring and Initializing Variables

To use a variable, you first have to declare it. You do this by giving it a name and specifying what type of data it will store. Here’s an example of declaring a variable in GDScript:

var player_name: String

In this example, we declared a variable named “player_name” that will store a string value. To initialize a variable, you give it a value when you declare it like this:

var player_name: String = "John Doe"

Data Types in GDScript

In GDScript, there are several data types that you can use to store different types of data. Here are the most common data types in GDScript:

    • Integer: Whole numbers, such as 1, 2, 3, etc.
var score: int = 10
    • Float: Numbers with decimal places, such as 1.5, 2.7, etc.
var price: float = 19.99
    • String: Text values, such as “hello”, “goodbye”, etc.
var player_name: String = "John Doe"
    • Boolean: A value that can either be “true” or “false”.
var game_over: bool = false
    • Array: A collection of values that can be of any data type.
var players: Array = [ "John Doe", "Jane Doe", "Jim Doe" ]
    • Dictionary: A collection of key-value pairs where each key is unique.
var player_scores: Dictionary = { "John Doe": 10, "Jane Doe": 20, "Jim Doe": 30 }

In the next section, we’ll learn about operators and expressions, which are used to manipulate data in your code.

Real-time strategy game made with Godot 4

Operators and Expressions

In this section, you’ll learn how to perform operations and manipulate data using operators and expressions in GDScript. We’ll cover different types of operators and how to use them in your code.

Arithmetic Operators

Arithmetic operators are used to perform basic arithmetic operations like addition, subtraction, multiplication, division, and more. Here are the most common arithmetic operators in GDScript:

    • +: Addition operator, used to add two values together.
var result = 2 + 2 # result will be 4
    • -: Subtraction operator, used to subtract one value from another.
var result = 5 - 2 # result will be 3
    • *: Multiplication operator, used to multiply two values.
var result = 2 * 2 # result will be 4
    • /: Division operator, used to divide one value by another.
var result = 4 / 2 # result will be 2
    • %: Modulus operator, used to find the remainder of a division operation.
var result = 7 % 3 # result will be 1

Assignment Operators

Assignment operators are used to assign values to variables. Here are the most common assignment operators in GDScript:

    • =: Simple assignment operator, used to assign a value to a variable.
var score = 10
    • +=: Addition assignment operator, used to add a value to a variable and then assign the result back to the same variable.
var score = 10
score += 5 # score will now be 15
    • -=: Subtraction assignment operator, used to subtract a value from a variable and then assign the result back to the same variable.
var score = 10
score -= 5 # score will now be 5
    • *=: Multiplication assignment operator, used to multiply a value with a variable and then assign the result back to the same variable.
var score = 10
score *= 2 # score will now be 20
    • /=: Division assignment operator, used to divide a value with a variable and then assign the result back to the same variable.
var score = 10
score /= 2 # score will now be 5

Comparison Operators

Comparison operators are used to compare two values and return a boolean value based on the comparison result. Here are the most common comparison operators in GDScript:

    • ==: Equality operator, used to check if two values are equal.
var result = 2 == 2 # result will be true
    • !=: Inequality operator, used to check if two values are not equal.
var result = 2 != 2 # result will be false
    • <: Less than operator, used to check if one value is less than another.
var result = 2 < 3 # result will be true
    • >: Greater than operator, used to check if one value is greater than another.
var result = 2 > 3 # result will be false
    • <=: Less than or equal to operator, used to check if one value is less than or equal to another.
var result = 2 <= 2 # result will be true
    • >=: Greater than or equal to operator, used to check if one value is greater than or equal to another.
var result = 2 >= 3 # result will be false

Logical Operators

Logical operators are used to perform operations on boolean values and return a boolean result. Here are the most common logical operators in GDScript:

    • and: Logical and operator, used to combine two boolean values and returns true only if both values are true.
var result = true and true # result will be true
    • or: Logical or operator, used to combine two boolean values and returns true if at least one value is true.
var result = false or true # result will be true
    • not: Logical not operator, used to negate a boolean value and returns the opposite value.
var result = not false # result will be true

3D Platformer made with Godot 4

Control Flow Statements

Control flow statements allow you to control the flow of execution of your code based on certain conditions. Here are the most common control flow statements in GDScript.

If Statement

The if statement allows you to execute a block of code only if a certain condition is met. Here’s an example:

if 2 > 1:
  print("2 is greater than 1")
# Output: 2 is greater than 1

If-Else Statement

The if-else statement allows you to execute a block of code if a certain condition is met, and another block of code if the condition is not met. Here’s an example:

if 2 < 1:
  print("2 is less than 1")
else:
  print("2 is not less than 1")
# Output: 2 is not less than 1

For Loop

The for loop allows you to execute a block of code repeatedly for a specific number of times. Here’s an example:

for i in range(3):
  print(i)
# Output:
# 0
# 1
# 2

While Loop

The while loop allows you to execute a block of code repeatedly as long as a certain condition is met. Here’s an example:

i = 0
while i < 3:
  print(i)
  i += 1
# Output:
# 0
# 1
# 2

Survival game made with Godot 4

Functions

Functions allow you to group a set of related code together and reuse it whenever you need it. Functions make your code more organized and readable. Here’s how to define and use functions in GDScript.

Defining Functions

You can define a function using the “func” keyword, followed by the function name, a list of parameters in parenthesis, and a block of code inside curly braces. Here’s an example:

func greet(name):
  print("Hello, " + name)

greet("John")
# Output: Hello, John

Return Statement

The return statement allows you to return a value from a function. Here’s an example:

func square(x):
  return x * x

result = square(3)
print(result)
# Output: 9

Optional Parameters

You can specify default values for parameters in case they are not provided when the function is called. Here’s an example:

func greet(name, greeting="Hello"):
  print(greeting + ", " + name)

greet("John")
# Output: Hello, John
greet("Jane", "Hi")
# Output: Hi, Jane

Variable Number of Parameters

You can accept a variable number of parameters by using the “*args” syntax. Here’s an example:

func sum(*numbers):
  result = 0
  for number in numbers:
    result += number
  return result

print(sum(1, 2, 3, 4))
# Output: 10

Skiing mini-game made with Godot 4

Classes and Objects

Classes and objects are fundamental concepts in object-oriented programming (OOP). They allow you to create complex data structures and provide a way to encapsulate data and behavior. Here’s how to use classes and objects in GDScript.

Defining Classes

You can define a class using the “class” keyword, followed by the class name and a block of code inside curly braces. Here’s an example:

class Person:
  var name

  func greet():
    print("Hello, my name is " + name)

person = Person.new()
person.name = "John"
person.greet()
# Output: Hello, my name is John

Constructor

The constructor is a special method that is automatically called when an object is created from a class. You can use the constructor to initialize the object’s properties. Here’s an example:

class Person:
  var name

  func _init(name):
    self.name = name

  func greet():
    print("Hello, my name is " + name)

person = Person.new("John")
person.greet()
# Output: Hello, my name is John

Inheritance

Inheritance allows you to create a new class that is a derived version of an existing class. The derived class inherits all the properties and methods of the base class. Here’s an example:

class Employee(Person):
  var company

  func work():
    print(name + " is working at " + company)

employee = Employee.new("Jane")
employee.name = "Jane"
employee.company = "Acme Inc."
employee.greet()
employee.work()
# Output:
# Hello, my name is Jane
# Jane is working at Acme Inc.

Polymorphism

Polymorphism allows you to use an object of a derived class anywhere an object of the base class can be used, because the derived class is considered a subclass of the base class. Here’s an example:

func introduce(person):
  person.greet()

introduce(person)
introduce(employee)
# Output:
# Hello, my name is John
# Hello, my name is Jane

Turn-based RPG made with Godot 4

Error Handling

Error handling is an important aspect of programming. It allows you to gracefully handle unexpected situations and prevent your program from crashing. Here’s how to handle errors in GDScript.

Try-Except Blocks

The try-except block allows you to wrap a block of code that might raise an exception, and handle the exception if it does. Here’s an example:

try:
  # code that might raise an exception
  print(1 / 0)
except DivisionByZero:
  # code to handle the exception
  print("Cannot divide by zero.")
# Output: Cannot divide by zero.

Raising Exceptions

You can raise an exception explicitly using the “raise” keyword, followed by an exception object. This allows you to signal that something unexpected has happened and stop the execution of the current function. Here’s an example:

func divide(a, b):
  if b == 0:
    raise ValueError("Cannot divide by zero.")
  return a / b

try:
  result = divide(10, 0)
  print(result)
except ValueError as error:
  print(error)
# Output: Cannot divide by zero.

Custom Exceptions

You can create your own custom exception classes to signal specific error conditions. Here’s an example:

class DivisionByZeroError(Exception):
  pass

func divide(a, b):
  if b == 0:
    raise DivisionByZeroError("Cannot divide by zero.")
  return a / b

try:
  result = divide(10, 0)
  print(result)
except DivisionByZeroError as error:
  print(error)
# Output: Cannot divide by zero.

Physics sandbox game made with Godot 4

File Input and Output

In this section, you’ll learn how to read from and write to files in GDScript. This is useful for storing data that you want to persist across multiple runs of your program.

Writing to Files

You can write to files using the “File” class in GDScript. Here’s an example that writes a message to a file:

var file = File.new()
file.open("message.txt", File.WRITE)
file.store_string("Hello, world!")
file.close()

In this example, we create a new “File” object, open a file named “message.txt” for writing, store the string “Hello, world!” in the file, and then close the file. If the file doesn’t exist, it will be created. If it does exist, its contents will be overwritten.

Reading from Files

You can read from files using the “File” class in GDScript. Here’s an example that reads a message from a file:

var file = File.new()
file.open("message.txt", File.READ)
var message = file.get_as_text()
file.close()
print(message)
# Output: Hello, world!

In this example, we create a new “File” object, open a file named “message.txt” for reading, retrieve the contents of the file as a string, and then close the file. We then print the contents of the file to the console.

Error Handling

When working with files, it’s important to handle errors that might occur, such as trying to open a file that doesn’t exist or trying to read from a file that hasn’t been opened for reading. Here’s an example that demonstrates error handling:

var file = File.new()
try:
  file.open("nonexistent.txt", File.READ)
except Error:
  print("Cannot open file.")
finally:
  file.close()
# Output: Cannot open file.

In this example, we create a new “File” object and attempt to open a file named “nonexistent.txt” for reading. If the file doesn’t exist, an “Error” exception will be raised and caught by the “except” block. We print an error message and then close the file in the “finally” block, which will be executed regardless of whether an exception was raised or not.

Conclusion

Congratulations, you’ve now learned the basics of GDScript! You can use this knowledge to create your own games and applications in Godot Engine.

However, there is more to learn than just GDScript. Godot offers a ton of fantastic features and tools – from simple tilemap painters to performant rendering options. Plus, these coding principles – while important – aren’t of any use unless you learn how to apply them practically to game projects.

To end this article, we’ve included a bunch of helpful resources below to help you get started on the next steps in your Godot journey. We hope this helps, and we’re looking forward to seeing what you do with Godot 4!

Primary Resources

Premium Godot Tutorials

Free Godot Tutorials

BUILD GAMES

FINAL DAYS: Unlock 250+ coding courses, guided learning paths, help from expert mentors, and more.

]]>
The Best Godot 4 Tutorials – Complete Game Dev Guide https://gamedevacademy.org/godot-4-0-tutorial/ Wed, 05 Apr 2023 05:29:37 +0000 https://gamedevacademy.org/?p=12194 Read more]]> Godot 4 is the newest major update for the Godot game engine. In January 2018, Godot 3.0 was released which introduced many new features such as a new rendering engine and improved asset pipelines. With the official release of Godot 4 in 2023, similar major advancements have come about that are sure to improve game development for users!

In this article, we’ll discuss some of the newest features for Godot 4 – and then show you where you can start learning!

Let’s dive in!

BUILD YOUR OWN GAMES

Get 250+ coding courses for

$1

AVAILABLE FOR A LIMITED TIME ONLY

Vulkan Rendering Engine

One of the major features for Godot 4 is the Vulkan rendering engine. It was introduced to the master branch of the engine back in February 2020, although OpenGL ES 3.0 is still supported. Godot 4 features full implementation of the Vulkan engine. So why make the change? Godot 3 is using OpenGL – which is supported on many platforms. But, as tech is moving forward, compatibility becomes much less of an issue using the Vulkain engine. Vulkan is also much more “lower-level” than OpenGL, allowing it to perform better and faster.

Core Engine Improvements

Godot 4 also features some major updates to the core of the engine. With an update like this, it’s given the developers an opportunity to make these much-needed changes. Here’s a few things that were changed:

  • Support for multiple windows
  • General cleanup of the API
  • Renaming of nodes and servers

Godot multiple windows.

New Lightmapper

Godot’s new lightmapper for 4 is so much of an improvement, that the devs are going to back-port it to Godot 3 as well. Lightmapping is pre-calculating the light for a game scene. This provides the benefit of having realistic lighting at a low computational cost. Here’s how the new lightmapper improves upon the older one while also making the experience easier for you as a developer.

  • GPU based – allowing for faster bake times
  • Easy to use – minimal number of parameters
  • Lightprobes
  • Automatic UV unwrapping

Other Improvement

While the three mentioned above are our favorite improvements, there have been a lot of other features and improvements added to the platform. These include:

  • Improved 2D tools and rendering
  • Shader and visual effects enhancements
  • Tweaks to both GDScript and C# for Godot
  • Overhauled physics
  • Stabilized networking for multiplayer games
  • Better animation tools and performance

Godot’s video below will help summarize everything with the release for your convenience as well (if you want to hear it from the horse’s own mouth, so to speak.

Summary of Godot 4’s Release

To sum it all up, the aim of Godot 4 is not necessarily to introduce a large number of new features, but to improve upon the rendering and engine performance in order to bring it up to the same level as other game engines out there.

However, the importance of a performant engine cannot be overstated – and puts Godot well in the arena to compete with engines such as Unity and Unreal Engine. Regardless, we hope this has excited you for this new release. Now is a fantastic time to learn a new tool if you’re in the market for one, or to re-familiarize yourself with Godot if you thought you knew everything about the engine already!

Without further ado, below we’ve put out our favorite tutorials for Godot 4 (along with some extra resources to speed up your learning process! Good luck, and we can’t wait to see your future Godot game projects!

Best Tutorials and Resources for Godot 4

Important Links

Demos & Key News

Premium Godot Tutorials

General Tutorials

BUILD GAMES

FINAL DAYS: Unlock 250+ coding courses, guided learning paths, help from expert mentors, and more.

]]>
What is Godot? The Free Engine for Making 2D & 3D Games https://gamedevacademy.org/what-is-godot/ Wed, 11 Jan 2023 01:00:10 +0000 https://gamedevacademy.org/?p=13232 Read more]]> While there are many game engines available, one you may have heard about through the grapevine is Godot.

Godot has recently seen a rise in the game development scene and is quickly becoming a favorite of many game developers! However, just as many developers have never heard of Godot, or even know why they might want to use Godot over other popular engines like Unity or Unreal. After all, game engine choice is crucial as a first step when developing your games.

In this post, we’re going to walk you through in not only understanding what the Godot game engine is, but also how it can benefit you as a game developer!

Let’s dive in and discover this amazing, free engine.

What is Godot?

First released in 2014 by Juan Linietsky and Ariel Manzur, Godot is a cross platform game engine oriented towards both 2D and 3D game development. The game engine focuses on providing a well-rounded set of tools for development – including a built-in code editor, a graphics rendering engine, audio playback tools, animation tools, and more. Over the years, the engine has grown immensely to include even more core contributors – and also accepts help from the Godot community as well to further develop the engine.

The Godot logo

Key Features

Let’s jump into some of the key features offered by the Godot game engine.

3D Graphics Support

As mentioned, Godot comes with many features needed for 3D graphics. This includes lighting systems, physics systems, material support (reflection, refraction, etc.), and even tools for post-processing effects. Further, the engine also supports more advanced graphics features such as shaders and particles, giving developers a full set of tools to customize their games.

Fully-Dedicated 2D Engine

Unlike other engines where 2D is achieved simply by flattening a single axis, Godot offers a true 2D engine. This means the engine can both handle 2D backend calculations efficiently, but also appropriately deal with pixel-based units. Further, the 2D game development suite comes with a number of dedicated tools such as tilemap editors, 2D physics support, and 2D lighting systems.

Screenshot of a 2D top down RPG made with Godot

Project Optimization with Nodes and Scenes

Godot is built heavily around the principle of object-oriented design. One of the primary ways it achieves this is with its node and scene architecture. Godot defines every object as a “scene”, and each scene can contain multiple nodes. Godot offers hundreds of nodes that provide base functionality to the game – whether it be collision detection, physics bodies, animations, sounds, etc. Basically, any baseline mechanic you might need to form more complex mechanics can be found as a node.

Due to this, Godot has made a unique system where it is extremely easy to add functions to objects at a very primitive level to create complex objects (i.e. “scenes”). This feature also has the benefit of letting beginners have tight control over inheritance between scenes as well as making instances much easier to handle, particularly compared to other engines.

Multiple Platform Support

Godot allows for deployment to several different platforms, including but not limited to Windows, macOS, Linux, iOS, and Android – all major contenders in the gaming market. Additionally, Godot also allows export for HTML5 for developers who wish to put their games on the web. While Godot does not offer support for consoles at this time due to several complicated factors, such as the console market being fairly unopen, many third-party companies do exist to help support developers who want to port their games to console devices.

Beyond this, Godot also has a robust plugin structure that allows developers to create virtual reality games and limited augmented reality applications as well.

The Godot Engine with a 2D character having the collision box added

Multiple Language Support

Out of the box, Godot allows developers to code their games in several different languages.

At the top of the list is GDScript, which is a scripting language developed specifically for working with Godot. As it was designed to integrate heavily with the Godot Engine itself, many developers have found it the most optimal for working with the engine. As it is similar in many respects to Python as well, developers also find its cleanliness and human readability a plus when developing with the engine.

For those who prefer not to code from scratch, Godot also comes with a visual scripting tool. This tool was designed to work extremely well with its node architecture, meaning non-programmers and beginners can easily use the drag-and-drop code blocks to construct their games.

However, for those more skilled, Godot also supports C++ and C# without much hassle as well – offering developers plenty of options. In addition to these two, Godot’s GDNative API also supports limited language binding, and some developers have found the ability to use languages such as Ruby or R with the engine.

Screenshot of Godot's build-in code editor creating a player

Animation System

Godot offers a robust set of tools for animation. Particularly for 2D, the engine comes with tools to allow developers to rig their 2D graphics and animate their graphics with full IK bone support. However, the engine also supports imported 3D animations as well as 2D sprite sheets. Regardless of the source, Godot also comes with various animator tools to help developers trigger and transition animations when needed.

Open Source

Godot is an open-source engine, meaning the source code for the engine code is publicly available (in this case, through a permissive MIT license). As such, developers with Godot are free to not only distribute the engine as they see fit, but also modify the engine in various ways without constraints.

This also means the engine is community-driven, and developers are free to contribute improvements to the engine code and offer experiences and tools that extend the engine in unique, robust ways. Plus, this means the engine is completely free in itself to use.

Godot Engine showing a 3D animation being made for a sword

What Can Be Made with Godot?

If you can dream it, Godot can probably help you make it. This includes FPS games, RPGs, strategy games, simulation games, turn-based deck builder games, and beyond. However, the best way to see what Godot is capable of is to check out some of their own developer showcases below of current and upcoming games – all made by developers just like you!

Why Choose Godot?

Now that we’ve talked about what Godot is and explored what it can do, let’s jump into the main thing many developers want to know: why should you choose Godot to develop games?

  1. 1. It’s free. As the engine is open-source, it costs you nothing to obtain or use the engine. Unlike Unity or Unreal Engine where a certain amount of revenue will cost you an expensive license, revenue made with Godot-created games are yours to keep with no strings attached!
  2. You can edit the engine as you need to. Again, the engine is open-source. So, if the engine doesn’t quite do what you need it to do for your game project, you can edit the engine directly until you can achieve the effect you want. This gives you the freedom you need to develop whatever systems and mechanics are needed without constraints!
  3. There are few limitations. Outside of performance and console games, Godot has few limitations. You can make games for mobile or even Linux. You can make action RPGs, farming simulation games, RTS games, or even point-and-click games. You can even make animations to just show off your animation skills. Godot doesn’t limit you with the tools they provide, so you can explore your creativity to its limits.
  4. The 2D Engine is generally considered better than other popular 3D engines. Mentioned above, Godot uses a dedicated 2D engine instead of simply pretending a third axis doesn’t exist. This makes it far more efficient at handling 2D graphics, 2D physics calculations, 2D lighting, and so forth compared to other engines like Unity and Unreal. So, if 2D is your aim, Godot definitely outranks a lot of the competition.Screenshot of a Mars city building type game made with Godot
  5. It’s lightweight. Many engines available are pretty hefty on computer systems, especially when they’re more graphics intense. Godot, however, is extremely lightweight, being less than 100MB. The resources it uses are also limited compared to other engines, meaning it is a fantastic engine choice if you have a low-powered system like a laptop as your only computing device.
  6. The engine is community-driven. Partly due to its open-source nature, Godot has attracted a dedicated following. Not only is there a steady stream of developers contributing to the engine’s development in the Godot community, but also tons of users who are ready and willing to answer questions and provide support as you build your game. There are also plenty of tutorials available as well to help users get started with building their own games.
  7. It’s beginner-friendly. Godot offers several tools to make game development very easy for beginners – whether that’s thanks to their visual scripting tools, GDScript’s readability, it’s easy to understand nodes to add functions, or so forth. Whether you’ve created a game before or not, Godot is easy to jump into. Even experienced developers often use Godot to prototype game mechanics simply due to how easy the engine is to use!
  8. Godot has strong version control support. Whether you’re using something popular like Git or other version control systems, Godot was made to be extremely compatible with a simple file setup. This means you can backup your various versions and not have to worry if you break something during the development process!

2D platformer example made with the Godot engine

How to Learn Godot

Interested in Godot after all is said and done? Below, we’ve compiled a list of resources that will allow you to explore the engine further and learn how to use it to create your own game projects!

Screenshot of a simple Action RPG made with the Godot Engine

Conclusion

We’ve only just grazed the surface on what Godot is here. However, hopefully you should have a much better understanding not only of what benefits the engine offers, but also how you might learn to utilize those benefits for your own game projects. Whether you’re looking to build some exciting 3D action RPGs or some simple 2D platformers, Godot is able to easily cater to your project needs. This is not to mention it is a great choice for beginners as well given how the engine has organized functionality into nodes for easy access. There is a lot to be had with this amazing tool, so get out there, make some games, and show just what you can do as a game developer!

BUILD GAMES

FINAL DAYS: Unlock 250+ coding courses, guided learning paths, help from expert mentors, and more.

]]>
How to Create a Game with Godot 4 – Beginner’s Tutorial https://gamedevacademy.org/godot-4-game-tutorial/ Mon, 09 Jan 2023 03:02:55 +0000 https://godottutorials.pro/?p=3819 Read more]]> Want to make games, but are tired of everything being about Unity and Unreal Engine?

Godot is a great game engine for both 2D and 3D games – making it a multi-purpose engine suitable for many kinds of projects. It’s also open source and has a strong community backing the project, so there are constant updates and new features being released. With the release of Godot 4, it’s also better than ever to explore game development with this fantastic tool.

In this tutorial, we’re going to be learning how to create a very simple coin collection game in Godot 4. We’ll discover not only some of the core tools offered by Godot, but how to use GDScript to render our various mechanics.

Without wasting any more time, let’s dive in!

Project Files

You can download the complete project we’ll be making in this tutorial here.

While we’ll include it later below, you may also wish to download the character sprite and coin sprite that we’ll be using as well.

BUILD GAMES

FINAL DAYS: Unlock 250+ coding courses, guided learning paths, help from expert mentors, and more.

Installing Godot

Right now, Godot 4 is in beta, so let’s go to the Beta Download Page and click Standard Build.

Downloads page showing the Standard build highlighted

Then, we want to click on the download that matches our operating system to begin the download.

Page showing the Godot 4 files available for download

Once that the download is complete, you should have a ZIP file which you can extract the contents of. The application file is the game engine, so we can double click on that to open it up.

User downloads folder with the Godot 4 beta application highlighted

Creating a Project

You should now have the Project Manager window open. This is where all of your Godot projects will be listed. For now, we have none, so let’s create one. Click on the New Project button.

Project Manager window in the Godot Engine with New Project circled

This will open up another window where we need to setup a few things.

  1. Choose a Project Name.
  2. Choose a Project Path. This will be where the project files are located on your computer.
  3. Then, click Create & Edit.

Create New Project window for Godot

Editor Overview

After you create the project, the Godot editor should open up. This is the window where we’ll be spending most of our time in creating our games. This is where we will manage our assets, build our levels and code our gameplay behaviors. At first, this may seem daunting. There are a number of different panels, buttons, and labels. But hopefully, as time goes on, it will all become second nature to you.

Blank Godot project as seen in the Godot editor

Let’s start by looking at what each of these panels do. First, in the center, we have our scene view. This is a window into our game and where we’ll be clicking on objects, dragging them in, and building our levels. At the moment, the engine is set to 3D, so that’s why we have a 3D view.

Godot Editor with the main Editor viewport circled

On the bottom left, we have our File System. This panel contains all of our assets (textures, models, sprites, sound effects, scripts, etc). It’s very similar to the file explorer on your computer.

Godot Editor with the File System panel circled

At the top left, we have the Scene panel. This here is a list of all the nodes currently in our scene. The way Godot works is with a node system. We’ll get more into that later, but it’s important to know that everything in your game (the player, camera, objects, lights, etc) are all nodes. And a scene is a collection of nodes.

Godot Editor with the Scene panel circled

On the right-hand side of our editor, is the Inspector. Whenever we select a node, this panel will populate to show us all of that node’s properties. Its position, rotation, scale and any other things that we might want to modify. If it’s a light node, then the inspector will allow us to change the color, brightness, range, angle, etc.

Godot Editor with the Inspector panel circled

At the top right corner of the screen, we have our play tools. These allow us to test out our game while we’re developing it. We can play, pause, stop, run the current scene, run a specific scene, or use the movie maker.

Godot Editor with a closeup of the play options for Godot

At the top center of the screen, we have a few buttons. These allow us to change what we see down in the large, center-scene viewport. Right now, it’s set to 3D, so that’s why we see our 3D scene. But we can easily switch over to 2D if that’s the type of game we want to create. When we start to code, we’ll be hopping over to the Script tab, as that’s where the text editor is contained.

Godot Editor showing the 2D, 3D, Script, and AssetLib options

For this tutorial though, we’ll be creating a 2D game. So let’s click on the 2D button to switch the window over to 2D mode.

Godot Editor with the 2D button clicked to make a 2D Godot project

Nodes

Now that we’re ready to begin, let’s go over to the Scene panel and create our first root node. Select the 2D Scene.

Godot Scene panel with 2D Scene selected as the Root Node

This is going to create our root node, which is now visible in the list. The way Godot works is through nodes. Everything in your game is nodes. 3D models, tiles, blocks, the player, enemies, UI – everything that can have a position in space or be instanced is going to be a node. Now with these nodes, they can be nested inside of each other. For example, a player node will also have a child node that acts as a collider. Another child node renders its sprite to the screen and another child node for the camera.

If you wish to learn more about Nodes and Scenes, check out the Godot documentation.

Now before we continue, let’s save our scene. A scene is basically a collection of nodes that can be loaded into our game. Press CTRL + S or go to Scene > Save Scene As to save. Let’s call it Level1.tscn, then click Save.

Creating the Player

Let’s get started on creating our player. We, first of all, need to figure out what node we want our player to be, because each node has a specific type. Each node type serves a different purpose, and for our player, we’ll be using a CharacterBody2D node. So to get started, go to the top right corner of the Scene panel, and click on the + icon.

In the Create New Node window, search for CharacterBody2D, select it, then click Create.

Godot CharacterBody2D node circled from the Create New Node window

This will create the node. Now we can double-click on it to rename the node. Rename it to Player.

Player node as seen in the Scene panel of Godot

Now that we have our root player node, we need to give them a visual.

Download this ZIP and extract the PNG inside.

With the image downloaded and extracted, drag it into the FileSystem panel to import.

Character sprite as seen in the Godot FileSystem

Now on our player node, right click it and select Add Child Node.

Add Child Node option highlight for the Player Node in Godot

Search for Sprite2D, select it and then click Create.

Create New Node window in Godot with Sprite2D selected

With the new child node selected, look over at the Inspector and you should see that the panel has a bunch of information. There is a texture property that we need to enter. From the FileSystem, click and drag the character sprite over into the field to assign it.

Sprite assigned to Sprite2D node in the Godot Inspector

Now we can zoom into the player in the scene view, but you’ll notice that it’s blurry.

Blurry sprite as seen in the Godot editor space

To fix this, select the sprite node, go to the inspector, and under the Texture drop-down, set Filter to Nearest.

Godot Inspector with Nearest set for the Texture filter of the Sprite2D node

Our player also needs a collider, so add a new child node of the type CollisionShape2D.

Player node with CollisionShape2D node added in Godot's Scene panel

In the inspector, you can set the Shape to be a RectangleShape2D. Then in the scene view, click and drag on the orange dots to fit it to our sprite.

2D collision box as seen in both the Godot Editor and in the Inspector

And there we go! We now have our player created. Let’s move on to coding, where we’ll get our player moving around.

Moving the Player

To move the player, we need to create a script. This is basically a text file that contains code. The engine can read that and apply whatever gameplay behaviors we define.

With the Player node selected, go down to the bottom of the inspector. Click on the down arrow next to Script and select New Script.

Node creation options with Script options shown

Call it Player.gd then click Create.

Attach Node Script window in Godot with Player script being created

This will then switch us from 3D mode to Script mode and we’ll see some default code here:

Godot script showing default code for movement

Delete everything except for the first line.

Clean Godot script with only "extends CharacterBody2D" left

Now let’s add in some code:

func _physics_process(delta):
  
    velocity = Vector2()
  
    if Input.is_key_pressed(KEY_LEFT):
        velocity.x -= 1
    if Input.is_key_pressed(KEY_RIGHT):
        velocity.x += 1
    if Input.is_key_pressed(KEY_UP):
        velocity.y -= 1
    if Input.is_key_pressed(KEY_DOWN):
        velocity.y += 1
    
    velocity *= 50	
    
    move_and_slide()

What we’re doing here is detecting inputs from the arrow keys, then changing the value of our velocity based on that. At the end, we’re multiplying it all by 50, so that we move at 50 pixels per second. And finally, move_and_slide will apply those changes to our CharacterBody2D.

If you now go to the top right corner of the screen and click on the Play button, you can test it out.

Godot project playing in editor

One thing you will notice, is that after you press play, a window will open. But our player is so small! And it’s in the top left corner of the screen. To fix this, we can go to our player node and add a new child node of type Camera2D.

Godot Scene panel with Camera2D node added to the Player node

Then in the inspector, make sure to enable Current. And for the Zoom, set that to 3, 3. This will make it so the camera is closer to the player and we can get a much better view of them.

Camera2D node in Godot's Inspector showing Zoom options

Now when you press play, it should look like this:

Godot project playing with zoom on character from Camera2D node

Collectibles

When we play our game, there’s one problem. There’s nothing to do! So let’s add in some coins that the player can collect.

To begin, download the coin sprite and import it into your project.

To begin, download the coin sprite and import it into your project.

Godot FileSystem showing a new tile sprite for coins available

Next, in the Scene panel, click on the + and create a new node of type Area2D. Make sure to rename it to Coin. Then as a child of Coin, add a Sprite2D node.

Coin node with Sprite2D node added in the Godot Scene panel

In the Inspector:

  • Set the Texture to be the coin sprite.
  • Set the Position to 0, 0.
  • Set the Filter to Nearest.

Select the Coin node, then at the top of the scene window, select the Move Tool. This will allow us to click and drag on the coin to move it around our scene.

Godot scene with the coin added and moved from behind the player

As a child of the Coin, create a CollisionShape2D node. Then in the Inspector, set the Shape to CircleShape2D. We can then click and drag on the orange circle to resize the collider.

Coin with the Collision2D node added to the coin node object in Godot

Finally, let’s create a script for the coin.

  1. Select the Coin node.
  2. In the inspector, create a new script called Coin.

Here’s what our Script panel should look like now.

Script Panel in Godot with the Coin script added

With the Coin selected, go over to the inspector and swap over to the Node tab. Here, we want to double-click on body_Entered(body: Node2D).

Node panel in Godot with body_entered circled under the Area2D options

In this window, select the Coin and click Connect. What we’re doing here is basically setting it up so that the coin script gets informed when a body hits the coin collider.

Connect Signal to a Method window in Godot with Coin circled

This new bit of code should then be added to the script automatically.

Godot coin script with new functionality automatically added

Delete the “pass” line of code and add these three new lines:

func _on_body_entered(body):
    body.scale.x += 0.2
    body.scale.y += 0.2
    queue_free()

What we’re doing here, is increasing the size of the colliding object (player) when they hit the coin. Then with queue_free(), we are destroying the coin so the player can only collect it once.

Back in our 2D panel, let’s make some more Coins. The best practice is to turn it into a scene. Much like how our level is saved as Level1.tscn, we are going to make our coin a scene. This means we can have many different instances of it in our scene which all inherit from the same blueprint. So to do this, click and drag the coin node into the FileSystem. Call it coin and click save.

Coin object node dragged to FileSystem in Godot

Now we can duplicate the coin (Ctrl + D) and move them around like so.

Godot scene with many instances of Coin added

Press play and we can test it out!

Play test of character and coins in Godot project

Conclusion

And there we go! We’ve made a small, introductory game with the Godot game engine. While this game is very simple, it does serve to not only show you what Godot 4 is all about, but some of the core tools you’ll be using in any Godot game project.

From here, you can expand upon our project, or create an entirely new game with the knowledge that you’ve learned. Perhaps you’ll want to turn this into a platformer with tons of jumping mechanics. Or maybe you want to make a bullet hell or even a strategy game. There is a ton left to explore, but hopefully these foundations will help you in taking that next step.

If you’re interested in learning more about the specifics with Godot, then you can read their documentation here. Thanks for following along, and good luck with your future Godot 4 games!

]]>