Explore Free Godot 3 Tutorials – GameDev Academy https://gamedevacademy.org Tutorials on Game Development, Unity, Phaser and HTML5 Tue, 11 Apr 2023 19:08:53 +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 3 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.

]]>
How to Create your First RPG UI in Godot https://gamedevacademy.org/godot-rpg-ui-tutorial/ Fri, 07 Apr 2023 05:00:35 +0000 https://gamedevacademy.org/?p=19841 Read more]]> Fact: the global RPG market is worth billions. Also fact: it’s no longer a realm for big gaming companies, but something solo and indie game developers can pursue as well.

If you’re looking to create your own games, you should definitely take into consideration making your own RPG. RPGs present you too with the opportunity to expand your coding and game design skills – as they incorporate lots of different game mechanics. However, no RPG really works without a UI, so this can’t be neglected as you develop your ideas.

In this Godot tutorial, we’re focusing on the implementation of UI elements for your RPG game. Here, we’ll be setting up a health bar together and we’ll also style a text label in order to display the amount of gold we have in the game.

Let’s dive in!

Project Files

In order to be able to follow along with this tutorial, you’ll need to download the assets found here. You can also download a copy of the source code files for the project done in the tutorial by clicking here.

BUILD YOUR OWN GAMES

Get 250+ coding courses for

$1

AVAILABLE FOR A LIMITED TIME ONLY

Creating the UI

Let’s start by creating the UI for our RPG game.

UI Scene

Let’s go up to Scene > New Scene:

Creating a new scene in Godot

We’re going to create a root node of ‘User Interface‘:

Select 'User Interface' for the root node

We’ll rename the node to “UI” and save the scene as “UI.tscn“:

Renaming the node to "UI"

Health Bar

Let’s right-click on our UI node and add a child node of type TextureProgress:

Adding a child node for the UI node in Godot

A TextureProgress is a bar, which can fill up a certain amount based on a given value:

TextureProgress bar in Godot

In the Inspector, we’ll drag in the image for our UI texture (UI > UI_WhiteSquare.png). into Textures > Under and Textures > Progress:

Dragging our UI texture image into the Textures' settings

We’ll also set Tint > Under to dark grey, Tint > Progress to red, and Range > Value to 50 so we can see that the progress is 50% of the way.

Enable ‘Nine Patch Stretch‘ so that the bar can be stretched to fit the size of the border:

Enabling 'Nine Patch Stretch' for the TextureProgress node in Godot

We’ll click and drag the anchor point down to the bottom left, so the health bar is snapped to the bottom left corner of the screen regardless of the screen size:

Snapping the health bar to the bottom left corner of the screen

Gold

Let’s create a new label node as a child of UI, and rename it to “GoldText”:

Creating a "GoldText" label for our UI node

Then position it above the health bar and extend it out sideways:

Positioning the GoldText node above the health bar on the screen

We’ll give it a sample text (“Gold: 500”) and align the text to the center:

Setting a sample text for our label in Godot

Sample text displaying on the screen

Custom Font

Let’s right-click on our font file (Font > Ubuntu-Regular.ttf), and click on “New Resource…“:

Adding a new font resource in Godot

… and create DynamicFont and save it as “Ubuntu-Regular.tres”:

Creating a DynamicFont in Godot

Save the new font as "Ubuntu-Regular.tres"

We’ll set the font size to 30 in the Inspector, and drag our font file (Ubuntu-Regular.ttf) into Font Data:

Setting up the new font's attributes in the Inspector

Now, let’s select the GoldText node, and assign a custom font here by dragging in the dynamic font (Ubuntu-Regular.tres) into Custom Fonts:

Assigning the dynamic custom font to the GoldText in Godot

Make sure that the anchor point of this node is also positioned at the bottom left corner of the screen:

Positionof the anchor point of the label node is at the bottom left corner of the screen

Implementing the UI

Now that our UI is all set up, let’s go back to our main scene and create a new node of type CanvasLayer:

Creating a new CanvasLayer node in Godot

Let’s drag in our UI (UI.tscn) as a child of the CanvasLayer:

Placing the UI.tscn as a child node of the CanvasLayer

UI node as a child of CanvasLayer in Godot

Our UI is now rendered on our screen:

UI rendered in Godot

UI Script

In the UI Scene, let’s go to our UI node and create a new script:

Creating a new script for our UI in Godot

Setting Up Variables

First of all, we’re going to be creating variables to get access to our UI nodes (get_node):

extends Control

onready var healthBar = get_node("HealthBar")
onready var goldText = get_node("GoldText")

Now we need to create a function for each of these variables, which will update their values.

Updating the Health Bar

Let’s update our health bar first. Note that the value of the health bar is a number between zero and 100. (0% ~ 100%):

extends Control 

onready var healthBar = get_node("HealthBar")
onready var goldText = get_node("GoldText")

# called when we take damage
func update_health_bar (curHp, maxHp):
  
  healthBar.value = (100 / maxHp) * curHp

We divided 100 by our maxHP to get the percentage value and then multiplied it by curHP to get our current health.

Updating the Text

Let’s update our gold text now. Make sure to include the text and the colon (“Gold :“) before the number:

Updating our gold text in Godot

extends Control

onready var healthBar = get_node("HealthBar")
onready var goldText = get_node("GoldText")

# called when we take damage
func update_health_bar (curHp, maxHp):
  
  healthBar.value = (100 / maxHp) * curHp


# called when our gold changes
func update_gold_text (gold):
  
  goldText.text = "Gold: " + str(gold)

Initializing The UI

Next, we need to connect this up to the actual Player node. Let’s open up our Player script:

Opening up the Player script in Godot

… and create a variable to get access to our UI node:

onready var ui = get_node("/root/MainScene/CanvasLayer/UI")

We need to initialize the UI inside of the ready() function for us to see the current values instead of the default values:

func _ready ():
  
  # initialize UI
  ui.update_health_bar(curHp, maxHp)
  ui.update_gold_text(gold)

Make sure that the UI node is placed at the top of the hierarchy as it’ll return an error otherwise. This is needed because Godot initializes and updates all their nodes from top to bottom:

Placing the CanvasLayer at the top of the hierarchy in Godot

The UI node must be placed above the Player node in order for the player script to access it.

Updating UI Elements

Finally, we have to update our UI values as we play. For that, let’s get our UI node to update the HP bar inside take_damage function:

func take_damage (damageToTake):
  
  curHp -= damageToTake
  ui.update_health_bar(curHp, maxHp)
  
  if curHp <= 0:
    die()

We also need to update the gold text inside give_gold function:

func give_gold (amount):
  
  gold += amount
  ui.update_gold_text(gold)

Now if we press play, you can see that our health starts to go down if we get attacked, and our gold goes up each time we collect a coin as expected:

UI elements updating correctly in Godot

Conclusion

Well done on completing this tutorial!

Here, you’ve learned how to implement the UI for your RPG game in Godot, something you can surely expand upon and also use in other game projects as well. This UI is also useable for any kind of subgenre you want to pursue as well – whether you want to go for an action RPG like we did or something more traditional and turn-based.

However, there’s a lot more to expand upon here even in the realm of UIs! Perhaps you want to create a second bar for mana, add a frame to your health bar, or even change the health bar’s shape entirely. There are endless possibilities even in this realm – in addition to learning tons of other core mechanics!

We hope that you have fun as you continue developing your games and wish you the best of luck in your future projects!

Want to learn more about RPGs in Godot? Try our complete Develop a 3D Action RPG with Godot 3 course.

BUILD GAMES

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

]]>
Intro to Strategy Tile Management Systems for Godot Games https://gamedevacademy.org/godot-tile-management-tutorial/ Thu, 06 Apr 2023 10:33:22 +0000 https://gamedevacademy.org/?p=19823 Read more]]> Strategy games are still one of the most popular genres – testing players’ decision-making abilities to achieve goals with limited resources.

However, they can involve some really taxing mechanics for developers as well to create, let alone balance to make a challenging but fun game. That said, with a smaller map and only a handful of different types of buildings or resources, we can already familiarize ourselves with the process of developing city-builders, which are a great start for any skill level!

In this Godot tutorial, you’ll learn how to map all the tiles of your grid in a way to know which ones have buildings on them and which are available to be selected next. We’ll also show you how to highlight tiles that are ready to receive buildings on them in each turn!

That said, let’s get started!

Project Files

Before you begin, note that some basic Godot experience is required, including knowledge of how to set up your project and create your tile map for the game. Aside from that, you can download a copy of the source code files for the project done in this tutorial here.

BUILD YOUR OWN GAMES

Get 250+ coding courses for

$1

AVAILABLE FOR A LIMITED TIME ONLY

Tile Script

To start, go over to the Tile scene and select the root node:

Selecting the Tile root node in Godot

Create a new script on our tile in the inspector:

Creating a new script for the Tile object in Godot

Let’s save the script as “Tile.gd”.

Creating Variables

In this script, we’ll create a boolean called ‘startTile’ using the keyword export. The export keyword allows us to set the value of the variable in the Inspector:

extends Area2D

export var startTile : bool = false

We will select the tile in the middle and set the ‘startTile‘ to be true (ticked):

Checking the startTile box in the Inspector tab in Godot

We need two more boolean variables to check whether or not this tile has a building on it, and also to check if we can place buildings on the selected tile:

extends Area2D

export var startTile : bool = false

var hasBuilding : bool = false
var canPlaceBuilding : bool = false

Functions Set Up

Now, we need to load two sprite components: one for highlighting the tiles, and one for building icons as follows.

extends Area2D

export var startTile : bool = false

var hasBuilding : bool = false
var canPlaceBuilding : bool = false

# components
onready var highlight : Sprite = get_node("Highlight")
onready var buildingIcon : Sprite = get_node("BuildingIcon")

The function below adds the current node to the “Tiles” group as soon as it appears in the scene tree:

func _ready ():
  
  add_to_group("Tiles")

Next, we’re going to create a toggle function that is going to be called whenever we want to enable/disable the Highlight. This will be used to check whether or not we can build on our tile:

func toggle_highlight (toggle):
  
  highlight.visible = toggle
  canPlaceBuilding = toggle

When we click on the tile, we will send over the Sprite to be displayed in our BuildingIcon:

func place_building (buildingTexture):
  
  hasBuilding = true
  buildingIcon.texture = buildingTexture

Detecting Clicks on the Tiles

We need also to add a signal to detect when we have clicked on the tile. With the “Tile” node selected, go to the Inspector and click on the Node panel:

Adding a signal to our Tile node in Godot

Let’s double-click on Input_event, select the “Tile“, and click on “Connect“:

Connecting the Input_event signal to the Tile node in Godot

With this, a new function has been created inside our Tile script:

extends Area2D

export var startTile : bool = false

var hasBuilding : bool = false
var canPlaceBuilding : bool = false

# components
onready var highlight : Sprite = get_node("Highlight")
onready var buildingIcon : Sprite = get_node("BuildingIcon")

func _ready ():
  add_to_group("Tiles")

func toggle_highlight (toggle):
  highlight.visible = toggle
  canPlaceBuilding = toggle
 
func place_building (buildingTexture):
  hasBuilding = true
  buildingIcon.texture = buildingTexture

func _on_Tile_input_event(viewport, event, shape_idx):
  pass # Replace with function body.

Scripting the Map

Our next step is to do the map script. The map script is going to be managing all of the tiles in our scene. It’s going to be managing tile replacement and tile highlighting.

Let’s create a new script on the “Tiles” node:

Selecting the Tiles in the MainScene in Godot

Creating a new script for the Tiles node in Godot

We’ll save the script as “Map.gd“:

Name the script "Map.gd"

First of all, we’re going to have an array for all the tiles, another for those tiles that have the buildings, and a float for the size of each tile:

extends Node

var allTiles : Array
var tilesWithBuildings : Array
var tileSize : float = 64.0

For information about Arrays, visit the documentation: https://docs.godotengine.org/en/stable/classes/class_array.html

Getting Tile at Given Position

We will now create a function to check whether there is a tile at a certain position on the grid and if so, it also checks if there’s no building on that tile. If both conditions are true, it will return that tile to us. Otherwise, we’ll return nothing (null):

extends Node

var allTiles : Array
var tilesWithBuildings : Array
var tileSize : float = 64.0

func get_tile_at_position (position):
  
  for x in range(allTiles.size()):
    if allTiles[x].position == position and allTiles[x].hasBuilding == false:
      return allTiles[x]  
      
  return null

Our next function will be called to disable every tile highlight, as we don’t want to see the highlights anymore once we’ve placed our buildings:

func disable_tile_highlights ():
  
  for x in range(allTiles.size()):
    allTiles[x].toggle_highlight(false)

Highlighting the Tiles

Following, we need to implement the main function for this script, which will be responsible for highlighting all the tiles we can place our building on:

func highlight_available_tiles ():

The function will loop through each of the tiles in the ‘tilesWithBuildings‘ array:

func highlight_available_tiles ():
  
  for x in range(tilesWithBuildings.size()):

…and check to see if the north, south, west, and east tiles can have a building placed on them. For that, we need to get those tiles relative to our selected tile position:

func highlight_available_tiles ():
  
  for x in range(tilesWithBuildings.size()):
    
    var northTile = get_tile_at_position(tilesWithBuildings[x].position + Vector2(0, tileSize))
    var southTile = get_tile_at_position(tilesWithBuildings[x].position + Vector2(0, -tileSize))
    var eastTile = get_tile_at_position(tilesWithBuildings[x].position + Vector2(tileSize, 0))
    var westTile = get_tile_at_position(tilesWithBuildings[x].position + Vector2(-tileSize, 0))

And then it is going to toggle/highlight the tiles:

func highlight_available_tiles ():
  
  for x in range(tilesWithBuildings.size()):
    
    var northTile = get_tile_at_position(tilesWithBuildings[x].position + Vector2(0, tileSize))
    var southTile = get_tile_at_position(tilesWithBuildings[x].position + Vector2(0, -tileSize))
    var eastTile = get_tile_at_position(tilesWithBuildings[x].position + Vector2(tileSize, 0))
    var westTile = get_tile_at_position(tilesWithBuildings[x].position + Vector2(-tileSize, 0))
    
    if northTile != null:
      northTile.toggle_highlight(true)
    if southTile != null:
      southTile.toggle_highlight(true)
    if eastTile != null:
      eastTile.toggle_highlight(true)
    if westTile != null:
      westTile.toggle_highlight(true)

And that is our map script all set:

extends Node

var allTiles : Array
var tilesWithBuildings : Array
var tileSize : float = 64.0

func get_tile_at_position (position):
  
  for x in range(allTiles.size()):
    if allTiles[x].position == position and allTiles[x].hasBuilding == false:
      return allTiles[x]  
      
  return null

func disable_tile_highlights ():
  
  for x in range(allTiles.size()):
    allTiles[x].toggle_highlight(false)
    
    
func highlight_available_tiles ():
  
  for x in range(tilesWithBuildings.size()):
    
    var northTile = get_tile_at_position(tilesWithBuildings[x].position + Vector2(0, tileSize))
    var southTile = get_tile_at_position(tilesWithBuildings[x].position + Vector2(0, -tileSize))
    var eastTile = get_tile_at_position(tilesWithBuildings[x].position + Vector2(tileSize, 0))
    var westTile = get_tile_at_position(tilesWithBuildings[x].position + Vector2(-tileSize, 0))
    
    if northTile != null:
      northTile.toggle_highlight(true)
    if southTile != null:
      southTile.toggle_highlight(true)
    if eastTile != null:
      eastTile.toggle_highlight(true)
    if westTile != null:
      westTile.toggle_highlight(true)

Now you’re ready to start placing the buildings of your game on top of the available tiles as you like!

Conclusion

Congratulations on finishing up the tutorial!

You’ve learned a lot about using a tile-based strategy system in Godot, including how to know which ones already have buildings, and how to highlight empty neighbor tiles. With the tile management implementation covered in this tutorial, we’ve tackled key components for many other sorts of strategy games as well!

From here, you can continue on developing different types of buildings you want to have for your game and customize each’s impact on resource generation. You can even move to bigger maps or create personalized ones! Make sure to use all your creativity moving forward and best of luck with your future Godot games!

Want to learn more about strategy games? Try our complete Construct a Strategy Game with Godot 3 course.

BUILD GAMES

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

]]>
A Guide to Adding Bullets for FPS Godot Games https://gamedevacademy.org/godot-bullet-fps-tutorial/ Thu, 06 Apr 2023 09:59:03 +0000 https://gamedevacademy.org/?p=19756 Read more]]> The first-person shooter (FPS) genre of video games is one of the most popular among players – with huge franchises like Call of Duty, HaloApex Legends, and many others.

While FPS games have a lot of different features that could be covered, there is one mechanic that stands above the rest: shooting. Even in a versatile environment with tons of different gun types, implementing the shooting of the bullets looks pretty much the same.

With that in mind, we’ve prepared this Godot tutorial where we’re going over the entire process of creating the bullet object and setting up its properties in the game engine. We’ll also cover the scripting of the projection of the bullets out of the gun being used in the game.

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

Project Files

You can download a copy of the source code files (including the assets) for the project done in this tutorial here.

BUILD YOUR OWN GAMES

Get 250+ coding courses for

$1

AVAILABLE FOR A LIMITED TIME ONLY

Creating The Bullet

We’re going to start by scripting the ability for our player to shoot. For that, let’s create a new scene and save it as “Bullet.tscn”:

Creating a new scene in Godot

Here, we’re going to create the bullet prefab that we’ll be spawning at the muzzle. Create a new root node of type Area, by clicking on ‘Other Node‘ and searching for “Area”:

Creating the bullet prefab by adding an Area root node in Godot

Area is a physics node that won’t actually collide with other objects, but it can detect collisions as something goes through its collider. This is useful for bullets as they don’t need to bounce off or collide with anything, we just need it to detect when it has entered another object:

Renaming our Area node to "Bullet" in Godot

Rename this node to “Bullet”, and drag the bullet model (Models > Weapon > ammo_pistol.obj) into the scene as a child node of Bullet:

Dragging the bullet model as a child of our Bullet node in Godot

Note that the “ammo_pistol.obj” asset we’re using here can be found in the project files link above.

In the inspector, set the Transform > Translation to (0, 0, 0) to center it in the scene and set the Scale to (10, 10, 10). Lastly, set the rotation to (90, 0, 0) so it is facing forward, not upward:

Setting up the bullet model in Godot

We’ll now add another child node (CTRL+A) of type CollisionShape to the root node Bullet:

Adding a CollisionShape node to our Bullet in Godot

Set the collider shape to ‘Capsule‘ in the Inspector. Then, click on the text “Capsule” to view more options and set the radius to 0.03 and the height to 0.06:

Setting up the collider's shape, radius, and height in Godot

Adding a Timer

We need to add just one more component (CTRL+A), which is a Timer, again as a child node of Bullet:

Adding a Timer as child node of Bullet in Godot

Timer is a node that waits for a given time (1 sec by default) and then emits a signal. A signal in Godot refers to an event that a node can call out once it meets a certain condition.

In the inspector, you can choose the Node tab and see the list of signals available:

Available signals for the Timer node in Godot

Back to the Inspector panel, let’s set the wait time to 5 and enable ‘Autostart’.  This will allow the timer to automatically start as soon as the game starts:

Setting up the Timer in Godot

Next, select the root node (Bullet) and create a new script by going to Script > [empty] > New Script:

Creating a new script in Godot

First of all, we are going to create variables for the speed and damage of our bullet as follows:

extends Area

var speed : float = 30.0
var damage : int = 1

To move the bullet forward, we can multiply the global transform on the z-axis (global_transform.basis.z) by speed and apply it directly on translation within func_process(). Note that delta is multiplied here to convert it from 30 units per frame to 30 units per second:

extends Area

var speed : float = 30.0
var damage : int = 1

func _process(delta):
  
  translation += global_transform.basis.z * speed * delta

Now we need to create another function that destroys the bullet whenever the bullet either runs out of the timer or hits an object. For this, we can use queue_free() which destroys the node:

func destroy ():
  
  queue_free()

Save the script. Go back to the Timer node, open up the Node panel, and double-click on the timeout() signal. It will ask us to connect a signal to a method.

In the Receiver Method input field, type in the name of the function to call (i.e. “destroy”) and hit ‘Connect’:

Connecting the Timer node to the destroy function

Our script now has this little green mark on the left which signifies that this function is connected to a signal. This function will be called once a signal is emitted:

The destroy function is now connected to a signal

Detecting An Enemy

Following, we need to be able to detect when the bullet enters another collider. Select the root node (Bullet) and open up the Node panel.

Double-click on ‘body_entered‘ and hit ‘Connect‘:

Detecting when the bullet collides with another object in Godot

We’re going to check if the object that the bullet collided with is an enemy (by checking if the object has a method called “take_damage“), and if true, we will call the “take_damage” function and send over the damage value:

func _on_Bullet_body_entered(body):
  
  if body.has_method("take_damage"):
    body.take_damage(damage)
    destroy()

Shooting Bullets

Let us now make it so that we can shoot the bullet from the game’s weapon.

Open up the player script file (Player.gd) and create a new variable to get a reference of the bullet scene:

onready var bulletScene = load("res://Bullet.tscn")

Then we need to create a function that will be called whenever we press down on the left mouse button:

func shoot ():

In this function, we’ll create a new bullet scene node using bulletScene.instance() in a variable called “bullet”:

func shoot ():
  
  var bullet = bulletScene.instance()

Then we need to give it a parent node so it can actually exist in our main scene. We can do this by using .add_child() function:

func shoot ():
  
  var bullet = bulletScene.instance()
  get_node("/root/MainScene").add_child(bullet)

Now we need to position it and orientate it where the muzzle is at:

func shoot ():
  
  var bullet = bulletScene.instance()
  get_node("/root/MainScene").add_child(bullet)
  
  bullet.global_transform = muzzle.global_transform

We have to subtract one from our ammo as well:

func shoot ():
  
  var bullet = bulletScene.instance()
  get_node("/root/MainScene").add_child(bullet)
  
  bullet.global_transform = muzzle.global_transform
  
  ammo -= 1

Finally, we need to call the shoot function whenever we press the shoot button. We will put it inside _process() as we need to check if the shoot button is pressed every frame. Also, ensure that the ammo is greater than 0:

func _process(delta):
  
  # check to see if we have shot
  if Input.is_action_just_pressed("shoot") and ammo > 0:
    shoot()

Note that the muzzle node should be facing the correct direction. If it’s facing the wrong direction, rotate it 180 degrees on the y-axis:

Rotate the muzzle node if facing the wrong way

Save and hit Play. We’re now able to shoot bullets from our gun:

Shooting bullets from our gun in Godot

Conclusion

Well done on completing this tutorial!

For those looking to build their own FPS, this is a huge step already! You can now shoot bullets from any weapon of your choice in your Godot game – with systems that make customizing your bullet assets easy!

FPS games make great projects for beginners and experience developers alike – but there’s more to do. Expanding your project further, you can design the game environment and the player’s choice of weapons as you see fit, apart from being able to add interactable pickup items and coding the enemy AI as you’d like. There are many more directions to go, but with the core shooting mechanics done you’re on the path to success!

We wish you the best of luck in your game development journey!

Want to learn more about FPS games in Godot? Try our complete Build a First-Person Shooter with Godot 3 course.

BUILD GAMES

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

]]>
How to Create Your First Player Character in Godot https://gamedevacademy.org/player-character-godot-tutorial/ Thu, 06 Apr 2023 09:14:51 +0000 https://gamedevacademy.org/?p=19693 Read more]]> Every game has its unique, core mechanics, but one thing they all share in common is the player character.

Whether first-person or third-person, designing the movement and behavior of the player is one of the first processes that we need to go through when creating games. This is important as it’s what characterizes how the players are expected to interact with the objects and obstacles of the game. Thus, knowing how to create players is a core skill for game development that cannot be skipped!

In this tutorial, we’ll cover the creation of a player character in Godot from the start – ranging from how to create the player node and add it to the game scene to how to configure the player’s sprite and set up the properties of its collider component.

All that said, let’s dive in!

Project Files

You can download a copy of the final source code files for the project done in this tutorial here.

BUILD YOUR OWN GAMES

Get 250+ coding courses for

$1

AVAILABLE FOR A LIMITED TIME ONLY

Creating the Player Sprite

Importing assets

After having created a new project in Godot, you first have to download the project assets available here to your computer.

Next, select and right-click the root folder in FileSystem, then go to ‘Open in File Manager‘:

Right-click on the root folder of the project in Godot and go to Open in File Manager option

This will open up a window with the files of our project. Now, with another window open with the assets you’ve downloaded from the link above, drag and drop the Sprites folder into the project folder:

Drag and drop the assets into the project folder

Or simply copy and paste them over so that they appear amongst the files of our project:

Importing assets to our project in Godot

Creating a Node to be our Player

To create our player, let’s click on ‘Scene’ and then ‘New Scene‘:

Click on Scene then 'New scene' to create our player in Godot

Select the ‘Other Node‘ option and search for “KinematicBody2D” in the ‘Create New Node’ window:

Search for KinematicBody2D when creating a new scene in Godot

Choose the ‘KinematicBody2D’ node and hit ‘Create’. The new node is now visible in the Scene window. Rename it to ‘Player‘ by double-clicking on it:

Rename the scene to Player

Adding a Sprite to the Player Node

Following, double-click the Sprites folder in the FileSystem to open it. Select the ‘Player_Idle‘ file and drag it into the viewport:

Drag the Player_Idle image to the viewport in Godot

This creates a new node as a child of the Player node:

Player_Idle is now a child node of the Player scene

In the inspector, go to Transform then click on ‘Position’. Set both x and y to 0:

Setting the position of the sprite to be the origin

The sprite is now centered in the origin (0, 0). Hit Ctrl+S to save the scene:

Sprite in origin position in Godot

Let’s also rename the sprite from ‘Player_Idle’ to ‘Sprite‘.

Adding a Collider to our Player

You’ll note that we’re having a node configuration warning next to our Player scene icon. It says that we need to add a collision child to define the shape of our KinematicBody node. To do that, right-click on the Player, and go ‘Add Child Node‘:

Adding a child node to our Player scene in Godot

Double-click on ‘CollisionShape2D‘ to create it:

Double-click on CollisionShape2D to create a new collision node

Go to Inspector and click on the arrow next to ‘Shape‘. Then select ‘New RectangleShape2D‘ as follows:

Setting up the collider node in Godot

To change the size of the collider, drag the red dots around to adjust the size so that it aligns with the whole sprite:

Adjusting the size of the collider shape in GodotCollider shape correctly adjusted to include the whole sprite size in Godot

Bringing the Player to the MainScene

At last, click on ‘MainScene‘. Go to FileSystem and drag the ‘Player.tscn‘ into the main scene:

Drag the Player.tscn into the main scene in Godot

Save the scene and click on the ‘Play‘ button:

Click on Play to run our scene in Godot

You’ll see that our player shows up in the game window:

Running our player scene in Godot

Scripting our Player in Godot

Let us now start scripting our player sprite.

Go to Project then click on ‘Project Settings…‘, and go over to the Input Map tab:

Project settings menu in Godot

Creating New Actions

We can create new actions for our sprite by adding in some new keys.

Write ‘move_left‘, ‘move_right‘ and ‘jump‘ then click on ‘Add‘ after each addition to include them to the list:

Adding action keys in Godot

We now need to assign each action a unique key. Simply click on the ‘+‘ button next to each action and press the relevant key on your keyboard:

Assigning a key to the added actions in Godot

In this tutorial, we’re going to use the left and right keys to move to the left and to the right, and the up key to jump. After confirming your choices, you can close the project settings window.

With the Player node selected, go to the Script tab in the Inspector panel. Expand it and click on ‘[empty]’. Then select ‘New Script‘ in the dropdown:

Creating a new script for our Player node in Godot

Hit the ‘Create‘ button:

Creating a new script in Godot

This will automatically open up a Scripting Interface as follows:

Script interface in Godot

Declaring Variables

A variable is basically a container that can hold data. The value may change depending on conditions or on commands passed to the program. To create our first variable, type ‘var‘ and then enter a variable name. After that, we can give it an initial value of zero by entering ‘ = 0‘:

extends KinematicBody2D

var score = 0

So now the score variable has a data type of int. You can also add a type hint with a colon (:) after the name to keep it as an integer, which is a whole number:

extends KinematicBody2D

var score : int = 0

You can also set a different data type, such as Vector2 or Sprite. Vector2 holds two numeric values that represent the x, and y coordinates of a point:

extends KinematicBody2D

var score : int = 0

var speed : int = 200
var jumpForce : int = 600
var gravity : int = 800

var vel : Vector2 = Vector2()

var sprite : Sprite = $Sprite

Note that the dollar sign ($) operator is used in front of Sprite. This basically tells the script to look through all of the children nodes and find the node of whatever type is defined after the $, which is Sprite in this case.

The alternate syntax to the dollar sign ($) operator is to use the get_node function. Simply replace $Sprite with get_node(“Sprite”):

var sprite : Sprite = get_node("Sprite")

We can also add a keyword called ‘onready‘ before ‘var’ to make sure the asset is ready when the scene loads:

onready var sprite : Sprite = get_node("Sprite")

This delays the initialization of the variable until the node of Sprite is found.

Moving the Player

Next, we will implement the ability for the player to move around and jump. First, we need to apply gravity. This is going to be done inside of a function called _physics_process():

func _physics_process(delta):

This is a built-in function of Godot, which gets called 60 times a second to process physics. First, we want to set out velocity on the x value to 0 as follows:

func _physics_process(delta):

  vel.x = 0

Then we will check our movement inputs, that is, if the Input system detects ‘move_left’ action:

func _physics_process(delta):

  vel.x = 0

  #movement inputs
  if Input.is_action_pressed("move_left"):

Our velocity on the x should be equal to negative ‘speed’ when we press the “move_left” button, and positive ‘speed’ when we press “move_right”:

func _physics_process(delta):

  vel.x = 0

  #movement inputs
  if Input.is_action_pressed("move_left"):
     vel.x -= speed
  if Input.is_action_pressed("move_right"):
     vel.x += speed

When moving a KinematicBody2D, you should not set its position property directly. Rather you should use the move_and_collide() or move_and_slide() methods. (*Note that these methods should be used within the _physics_process() callback.)

The move_and_slide() method moves the body along a given vector, and if the body collides with another, it will slide along the other body. This is especially useful in platformers or top-down games.

To use the move_and_slide(), we need first to send over the velocity and the direction in which the floor is pointing. Since the ground will be below us, this would be Vector2.Up:

func _physics_process(delta):

  vel.x = 0

  #movement inputs
  if Input.is_action_pressed("move_left"):
     vel.x -= speed
  if Input.is_action_pressed("move_right"):
     vel.x += speed

  #applying the velocity
  move_and_slide(vel, Vector2.UP)

Flipping the Sprite

Now, we can assign it to our velocity and check which direction our player sprite should be facing:

func _physics_process(delta):

  vel.x = 0

  #movement inputs
  if Input.is_action_pressed("move_left"):
     vel.x -= speed
  if Input.is_action_pressed("move_right"):
     vel.x += speed

  #applying the velocity
  vel = move_and_slide(vel, Vector2.UP)

  #sprite direction
  if vel.x < 0:
     sprite.flip_h = true
  elif vel.x > 0:
     sprite.flip_h = false

Save the script and press Play:

Moving the sprite to the right in GodotMoving the sprite to the left in Godot

You can now move the Player horizontally with arrow keys. The sprite will flip as the moving direction changes.

Applying Gravity

To implement gravity is pretty straightforward, we can simply add it directly onto our y velocity:

func _physics_process(delta):

  vel.x = 0

  #movement inputs
  if Input.is_action_pressed("move_left"):
     vel.x -= speed
  if Input.is_action_pressed("move_right"):
     vel.x += speed

  #applying the velocity
  vel = move_and_slide(vel, Vector2.UP)

  #gravity
  vel.y += gravity * delta

  #sprite direction
  if vel.x < 0:
     sprite.flip_h = true
  elif vel.x > 0:
     sprite.flip_h = false

When you add/subtract from the velocity, it needs to be multiplied by delta so that it accelerates at the correct speed:

#gravity

vel.y += gravity * delta

Jump Input

We need to check if the ‘jump’ key is detected, and we also need to check if the player is on the floor:

#jump input
if Input.is_action_just_pressed("jump") and is_on_floor():

We then want to apply the jump force in the opposite direction of gravity:

#jump input
if Input.is_action_just_pressed("jump") and is_on_floor():
  vel.y -= jumpForce

Make sure you have saved the script:

extends KinematicBody2D 
 
var score : int = 0 
 
var speed : int = 200 
var jumpForce : int = 600 
var gravity : int = 800 
 
var vel : Vector2 = Vector2()
 
onready var sprite : Sprite = get_node("Sprite")

func _physics_process(delta):
  
  vel.x = 0
  
  #movement inputs
  if Input.is_action_pressed("move_left"):
    vel.x -= speed
  if Input.is_action_pressed("move_right"):
    vel.x += speed
  
  #applying the velocity
  vel = move_and_slide(vel, Vector2.UP)
  
  #gravity
  vel.y += gravity * delta
  
  #jump input
  if Input.is_action_just_pressed("jump") and is_on_floor():
    vel.y -= jumpForce
    
  #sprite direction
  if vel.x < 0:
    sprite.flip_h = true
  elif vel.x > 0:
    sprite.flip_h = false

* Note that if you press the play button now, the character will simply fall. That happens because there’s no ground for the player to interact with, as we’re not implementing it in this tutorial. You can think of this as a challenge for yourself!

Conclusion

Well done on completing this tutorial on how to create a player with Godot!

Although there’s much to expand here, you’ve already learned how to script your player in Godot and how to set up the player’s sprite and kinematic properties so it behaves as desired! You can now move on to coming up with your game’s level style and structure, besides some enemy logic or coin collection to make your game exciting.

Godot is also a great choice for beginners – as its node-based user interface makes it easy to create games while also facilitating access and project organization. Plus, the engine is open source and has a strong community backing the project, so there are constant updates and new features being released all the time.

We wish you all the best of luck with your game projects, and that you continue learning more each day!

Further Resources

Would you like to see more on Godot? Check out our recommendations to help you on your journey below:

Want to learn more about developing in Godot? Try our complete Godot 3 Game Development for Beginners course.

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.

]]>
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.

]]>
A Guide to Third-Person Controllers https://gamedevacademy.org/third-person-controller-tutorial/ Fri, 03 Jul 2020 01:00:53 +0000 https://godottutorials.pro/?p=3572 Read more]]>

You can access the full course here: Develop a 3D Action RPG with Godot

 

Player Setup

In this lesson, we are going to begin to create our player.

Creating Player Scene

Click on Scene > New Scene.

Godot Scene menu with New Scene selected

Click on Other Nodes in the Scene window.

Godot scene tab with Other Node selected

Search for ‘KinematicBody‘ in the Create New Node window.

KinematicBody option in Godot

Select the ‘KinematicBody‘ node and hit ‘Create‘.

KinematicBody node description

The new node is now visible in the Scene window. Rename it to “Player”.

Godot scene with new Player scene added

Save the scene as “Player.tscn”.

Player.tscn in Godot FileSystem

Creating Components (1) – Mesh

Right-click on the player node and select ‘Add a child’ (Ctrl+A)

Add Child Node option in Godot menu

Create a new MeshInstance.

MeshInstance Node option

Click on ‘Mesh‘ and select ‘New CapsuleMesh‘ in the Inspector.

CapsuleMesh option in Godot

Set the radius to be 0.5, the y-translation to be 1, and the x-rotation to be 90.

Godot Inspector for player mesh object

Creating Components (2) – CollisionShape

Create another child of type CollisionShape.

Player scene with child nodes

Set the Shape to be ‘Capsule’, the radius to be 0.5, the y-translation to be 1, and the x-rotation to be 90, so it matches up with our capsule mesh.

Player with CollisionShape options in Inspector

Creating Components (3) – Camera

Create a child node of the player, which is of type Camera.

Player with Camera child node

Create another child of type Spatial and rename it to “CameraOrbit”. Drag in the camera as a child.

CameraOrbit set up with Camera child in Godot

Set the CameraOrbit‘s position to be (0, 1, 0) so it can be orbiting around the center of the player.

Player mesh object in Godot editor

Godot Inspector for Spatial translation

Set the camera position to be (-1, 1, -5) and the rotation to be (0, 180, 0). Click on the ‘Preview‘ to see our default camera view in game.

Preview screen of Godot action RPG project

Creating Components (4) – Weapon Holder

Create a new Spatial node and rename it to be “WeaponHolder”. Set the position to be (-0.58, 1, 0.035)

Spatial camera settings with further translation adjustments

Drag in the sword model file (Models > Sword.dae) as a child of WeaponHolder. Set the position to be (0, 0, 0), the size to be (0.15, 0.15, 0.15) and the rotation to be (0, 90, 45).

Weapon Holder node with Sword model as child

Player capsule with sword in Godot

Inspector for sword model in Godot

Creating Components (5) – Attack Ray Cast

Create a node of type RayCast. This is going to be how we detect if we’re looking at an enemy when we attack them.

RayCast node added to Player scene in Godot

Set the properties as below, so it is in the middle of the player but a little bit forward of the sword.

Inspector for RayCast node

Player with RayCast hitbox

Finally, drag in the player scene (Player.tscn) into the main scene and set the position to be (0, 0, 0) so they’re in the middle of the level.

Godot game project with Player scene added to game scene

Camera Setup

In this lesson, we’re going to set up a camera look.

Click on the CameraOrbit node and create a new script.

Player with Script added to node

Save the script as “CameraOrbit.gd”.

GDScript Node script

In the script, we’ll create a float variable called lookSensitivity, and set its default value to be 15.0.

 

extends Spatial

var lookSensitivity : float = 15.0

This is going to be based on how fast our mouse moves.

We’ll then set up the min/max angles for the vertical rotation of the camera.

extends Spatial

var lookSensitivity : float = 15.0
var minLookAngle : float = -20.0
var maxLookAngle : float = 75.0

Now we need to keep track of the mouse delta, which tells how fast and in what direction did the mouse move for each frame. This is going to be Vector2 for an X and Y in screen coordinates.

extends Spatial

var lookSensitivity : float = 15.0
var minLookAngle : float = -20.0
var maxLookAngle : float = 75.0

var mouseDelta : Vector2 = Vector2()

Lastly, we need to get access to our parent (player) node. Note that the onready keyword is used to ensure that the node is found as soon as the game starts.

extends Spatial

var lookSensitivity : float = 15.0
var minLookAngle : float = -20.0
var maxLookAngle : float = 75.0

var mouseDelta : Vector2 = Vector2()

onready var player = get_parent()

Now, we’re going to use a built-in function called _input(event). The event parameter contains all the information of whatever’s being pressed on your input devices (e.g. keyboard).

func _input(event):

Using this event parameter, we can get how fast and in what direction the mouse has moved each frame. We’ll store this into our mouseDelta variable.

func _input(event):
	
	if event is InputEventMouseMotion:
		mouseDelta = event.relative

We can then create another built-in function called _process(delta), which will be called 60 times a second.

func _process(delta):

The delta parameter is the duration between each frame, and we can use this to do stuff based on ‘per second’ rather than ‘per frame’.

Now we want to get the rotation– what rotation are we going to be applying to the camera / our player? This will be stored in a variable called “rot” as a Vector3 (X,Y,Z).

func _process(delta):
	
	var rot = Vector3(mouseDelta.y, mouseDelta.x, 0) * lookSensitivity * delta

We’ll assign mouseDelta.y for the x, because if we’re moving along the x-axis, it will be vertical movement (up and down). For the same reason, we’ll apply MouseDelta.x for the y, and zero for the z.

Now we need to apply this rotation to the camera and to the player. Let’s apply the vertical rotation first (x -axis)

func _process(delta):
	
	var rot = Vector3(mouseDelta.y, mouseDelta.x, 0) * lookSensitivity * delta
	
	rotation_degrees.x += rot.x

Currently, if we keep moving our mouse up, it’s going to eventually do a loop around the player. Hence, we’ll clamp the position:

func _process(delta):
	
	var rot = Vector3(mouseDelta.y, mouseDelta.x, 0) * lookSensitivity * delta
	
	rotation_degrees.x += rot.x
	rotation_degrees.x = clamp(rotation_degrees.x, minLookAngle, maxLookAngle)

Now we need to rotate it sideways, but this time we’re not going to be rotating the camera, we’re going to rotate the entire player.

func _process(delta):
	
	var rot = Vector3(mouseDelta.y, mouseDelta.x, 0) * lookSensitivity * delta
	
	rotation_degrees.x += rot.x
	rotation_degrees.x = clamp(rotation_degrees.x, minLookAngle, maxLookAngle)
	
	player.rotation_degrees.y -= rot.y

Finally, we’ll clear our mouse delta so we won’t keep rotating around in the same direction if we stop our mouse.

func _process(delta):
	
	var rot = Vector3(mouseDelta.y, mouseDelta.x, 0) * lookSensitivity * delta
	
	rotation_degrees.x += rot.x
	rotation_degrees.x = clamp(rotation_degrees.x, minLookAngle, maxLookAngle)
	
	player.rotation_degrees.y -= rot.y
	
	mouseDelta = Vector2()

At the start of the game, the mouse cursor should be captured in the center, so our mouse doesn’t fall off the screen. This can be done in the _ready() function, which is called once when the node is initialized.

func _ready():
	
	Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
extends Spatial

var lookSensitivity : float = 15.0
var minLookAngle : float = -20.0
var maxLookAngle : float = 75.0

var mouseDelta : Vector2 = Vector2()

onready var player = get_parent()

func _ready():
	
	Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)

func _input(event):
	
	if event is InputEventMouseMotion:
		mouseDelta = event.relative

func _process(delta):
	
	var rot = Vector3(mouseDelta.y, mouseDelta.x, 0) * lookSensitivity * delta
	
	rotation_degrees.x += rot.x
	rotation_degrees.x = clamp(rotation_degrees.x, minLookAngle, maxLookAngle)
	
	player.rotation_degrees.y -= rot.y
	
	mouseDelta = Vector2()

We can now rotate our camera around the player as much as we want and our mouse won’t fall off the screen. (Press Alt+F4 to quit the game window)

Godot scene with orbiting camera

Inputs & Player Script

In this lesson, we’re going to begin to script our player.

Setting Up Input Keys

Go to Project > Project Settings…

Project menu in Godot with Project Settings selected

Open up the ‘Input Map‘ tab in the project settings.

Godot Input Map tab

In this window, we can create new actions by giving the action names.

  • ‘move_forward’
  • ‘move_backward’
  • ‘move_right’
  • ‘move_left’
  • ‘jump’
  • ‘attack’

Input Map in Godot with new move being added

We can then assign a unique key for each action by clicking on the ‘+’ button and pressing the relevant key on your keyboard.

New input move in Godot with Key selected for input

Key input confirmation window

We’ll move with W/A/S/D, jump with Space, and attack with the LMB.

Final movement set up in Godot Input Map

Once that’s all set up, close the project settings window.

Creating a new script

With the Player node selected, if you go to the Inspector panel, you will see that there is a Script tab. Expand it and click on [empty]. Then select ‘New Script’ in the dropdown.

Script menu with New Script selected

Hit on the ‘Create’ button.

Attach Node Script window

This will automatically open up a Scripting Interface.

Godot script window for Player.gd file

Scripting The Player

First of all, we’re going to create variables for our game– starting with the basic stats.

extends KinematicBody

var curHp : int = 10
var maxHp : int = 10
var damage : int = 1

Later on, we’re going to implement gold so we can collect coins.

extends KinematicBody

var curHp : int = 10
var maxHp : int = 10
var damage : int = 1

var gold : int = 0

We also need to know for attacking, how often can we attack? What’s the minimum amount of time between clicks?

extends KinematicBody

var curHp : int = 10
var maxHp : int = 10
var damage : int = 1

var gold : int = 0

var attackRate : float = 0.3
var lastAttackTime : int = 0

We need to create variables for physics stuffs, such as moving and jumping.

extends KinematicBody

var curHp : int = 10
var maxHp : int = 10
var damage : int = 1

var gold : int = 0

var attackRate : float = 0.3
var lastAttackTime : int = 0

var moveSpeed : float = 5.0
var jumpForce : float = 10.0
var gravity : float = 15.0

var vel : Vector3 = Vector3()

Finally, we’re going to get access to our Camera and Raycast.

extends KinematicBody

var curHp : int = 10
var maxHp : int = 10
var damage : int = 1

var gold : int = 0

var attackRate : float = 0.3
var lastAttackTime : int = 0

var moveSpeed : float = 5.0
var jumpForce : float = 10.0
var gravity : float = 15.0

var vel : Vector3 = Vector3()

onready var camera = get_node("CameraOrbit")
onready var attackRayCast = get_node("AttackRayCast")

Now, we’ll reset our velocity inside physics_process(), which gets called 60 times a second. This is so that we can stop immediately when we’re not pressing a button.

func _physics_process(delta):
	
	vel.x = 0
	vel.z = 0

Now we’ll store our input in a vector3 component whenever we press on a button. If an action is pressed, we need to modify this input vector accordingly.

func _physics_process(delta):
	
	vel.x = 0
	vel.z = 0
	
	var input = Vector3()
	
	if Input.is_action_pressed("move_forward"):
		input.z += 1
	if Input.is_action_pressed("move_backward"):
		input.z -= 1
	if Input.is_action_pressed("move_left"):
		input.x += 1
	if Input.is_action_pressed("move_right"):
		input.x -= 1

The magnitude of this vector is all the three axes (X,Y,Z) added together. So if we’re moving forward, the magnitude is going to be 1.

If we’re moving forward and left, the magnitude of that is going to be 2. This will result in moving twice the speed if we move diagonally. We can prevent this by normalizing the vector.

func _physics_process(delta):
	
	vel.x = 0
	vel.z = 0
	
	var input = Vector3()
	
	if Input.is_action_pressed("move_forward"):
		input.z += 1
	if Input.is_action_pressed("move_backward"):
		input.z -= 1
	if Input.is_action_pressed("move_left"):
		input.x += 1
	if Input.is_action_pressed("move_right"):
		input.x -= 1
		
	input = input.normalized()

Now we need to figure out which direction we are facing because when we press left or right, we want to move based on our local direction (instead of the global direction).

This can be done by multiplying our forward direction (transform.basis.z) by our z input, plus our right direction (transform.basis.x) by our x input.

func _physics_process(delta):
	
	vel.x = 0
	vel.z = 0
	
	var input = Vector3()
	
	if Input.is_action_pressed("move_forward"):
		input.z += 1
	if Input.is_action_pressed("move_backward"):
		input.z -= 1
	if Input.is_action_pressed("move_left"):
		input.x += 1
	if Input.is_action_pressed("move_right"):
		input.x -= 1
		
	input = input.normalized()
	
	var dir = (transform.basis.z * input.z + transform.basis.x * input.x)

Finally, we can apply the product (dir * moveSpeed) to our velocity.

func _physics_process(delta):
	
	vel.x = 0
	vel.z = 0
	
	var input = Vector3()
	
	if Input.is_action_pressed("move_forward"):
		input.z += 1
	if Input.is_action_pressed("move_backward"):
		input.z -= 1
	if Input.is_action_pressed("move_left"):
		input.x += 1
	if Input.is_action_pressed("move_right"):
		input.x -= 1
		
	input = input.normalized()
	
	var dir = (transform.basis.z * input.z + transform.basis.x * input.x)
	
	vel.x = dir.x * moveSpeed
	vel.z = dir.z * moveSpeed

Gravity, Jumping, and More

In this lesson, we’re going to be implementing gravity and jumping.

Applying Gravity

We need to gradually decrease our y velocity over time so that we fall.

In real life, the gravity value is about 9.8 (m/s2), but we’ve set it to 15 because a low gravity that is close to the real-life gravity doesn’t actually feel that great in video games. This is because in most video games, you’re jumping at much greater heights than you would in real life.

var gravity : float = 15.0

# gravity
vel.y -= gravity * delta

The delta here makes it easy for us to set the gravity value so that we fall at an appropriate speed.

Detecting Jump Input

We need to detect for when we press Space bar and if we’re standing on the floor.

if Input.is_action_pressed("jump") and is_on_floor():

If so, we’re setting the velocity to be jump force, so we’re instantly shooting up into the air.

	# gravity
	vel.y -= gravity * delta
	
	if Input.is_action_pressed("jump") and is_on_floor():
		vel.y = jumpForce

And then, if we’re no longer pressing the jump button, gravity is going to be taking over from there.

Moving along the current velocity

Next, we’re going to be setting our velocity to the move_and_slide function.

	# gravity
	vel.y -= gravity * delta
	
	if Input.is_action_pressed("jump") and is_on_floor():
		vel.y = jumpForce
		
	# move along the current velocity
	vel = move_and_slide(vel, Vector3.UP)

This is useful as it moves us along that velocity, considering that the up direction is where the floor is. This means we can detect if we’re standing on the floor and if we’re going to be colliding with anything so that we can bump into them and stop moving.

That is our player controller set up and complete.

extends KinematicBody

var curHp : int = 10
var maxHp : int = 10
var damage : int = 1

var gold : int = 0

var attackRate : float = 0.3
var lastAttackTime : int = 0

var moveSpeed : float = 5.0
var jumpForce : float = 10.0
var gravity : float = 15.0

var vel : Vector3 = Vector3()

onready var camera = get_node("CameraOrbit")
onready var attackRayCast = get_node("AttackRayCast")

# called every physics step (60 times a second)
func _physics_process(delta):
	
	vel.x = 0
	vel.z = 0
	
	var input = Vector3()
	
	# movement inputs
	if Input.is_action_pressed("move_forward"):
		input.z += 1
	if Input.is_action_pressed("move_backward"):
		input.z -= 1
	if Input.is_action_pressed("move_left"):
		input.x += 1
	if Input.is_action_pressed("move_right"):
		input.x -= 1
	
	# normalize the input vector to prevent increased diagonal speed
	input = input.normalized()
	
	# get the relative direction
	var dir = (transform.basis.z * input.z + transform.basis.x * input.x)
	
	# apply the direction to our velocity
	vel.x = dir.x * moveSpeed
	vel.z = dir.z * moveSpeed
	
	# gravity
	vel.y -= gravity * delta
	
	if Input.is_action_pressed("jump") and is_on_floor():
		vel.y = jumpForce
		
	# move along the current velocity
	vel = move_and_slide(vel, Vector3.UP)

If you save and hit Play, you can now use the WASD keys to move left/right/back/forwards and jump with space.

Action RPG in Godot with moveable player

Transcript

Player Setup

Welcome back everyone. In this lesson, we’re gonna begin to create our player character and this player is gonna do a few things. First of all, it’s gonna be a third-person character, meaning that we’re gonna be able to see the player. We’ll be able to then rotate the camera around and move around and jump around as well.

So to begin, let’s go ahead to create a new scene here. And this is gonna be of type kinematic body. Now a kinematic body node, is basically a physics node which is really useful for if you want moving characters that can collide with environments, can walk over things, can detect when they’re standing on the ground and a bunch of other things that you might want for a physics character body. I’m gonna rename this here to our player. I’m gonna then save the scene as player.tscn and now for our player, we need to add in a few things.

First of all, we need to be able to see our player, so let’s add in a primitive mesh, which is gonna just be a capsule model. Although if you do have a model for the player that you want to use you can of course do that. I’m just gonna go add child node. I’m gonna then go mesh instance right here and this mesh instance, we can go over to the inspector. And in here what we want to do is set the mesh to be a new capsule mesh right here. We’ll select that so it opens up the properties, let’s set the radius to 0.5 and we’ll set the mid-height here to, we’ll keep that at one. But as you can see, it’s pretty much sideways.

So let’s go down to, let’s close this up. Let’s go down to transform. I gonna set the translation here to be one on the Y. And on the rotation degrees I gonna set 90 on the X. So it is facing upwards like that. There we go. Okay, so we’ve got the player capsule. Now let’s just rename this to Model.

I’m then gonna add in a collision shape as that’s what the kinematic body requires. ‘Cause right now we don’t have a collider so we’ll just fall right through the floor. So add child node, collision shape right here. Create that, set the shape to be the exact same as the model. So we’ll set it as a capsule shape. We’ll set the radius to be 0.5. We’ll set the transform translation on the wire to be one and the rotation degrees on the X to be 90, so it matches up with our capsule right here. Okay, so we’ve got the main player objects set up right here.

Now what we need to do is create our camera. Now for our camera Godot has an easy camera node, we can just create and that will render the scene for us automatically. So let’s go to player, we’re right click on that, add child node, and we want to add in a camera right here. So there we go. We got our camera.

But what we want to do, is have the ability to have this camera over here for example, like just behind the player a bit and then have it actually rotate around, sort of orbit around the player. Now we could do this in a script by calculating the center position of the player relative to our position and then do some maths to figure that out. But that’s a bit overcomplicated for what we really need. And to make this a lot easier, what we can do is make this camera a child of an empty node, which is gonna be in the middle of the player and instead of rotating the camera, we’ll rotate that node around just on its axes. That won’t move around at all. So that will make it much easier to move around the camera.

So I’m gonna create a new node as a child of player here. This one is just gonna be a spatial node and with this spatial node what we want to do is rename it to camera orbit. Let’s set it to the middle position of the player. So it’s at the feet right now, but let’s move it up a bit. So maybe we’ll set the translation on the Y to be one. So it is sort of gonna be orbiting around the center of the player right there. And now what we want to do is just drag in the camera as a child.

For our camera, let’s set it to a position. So in transform we’ll set the translation on the X to be negative one, Y is gonna be one and Z is gonna be negative five. There we go. The reason why it’s over here and not over here is because we want the player to be facing by default in the forward direction. And that is along the blue axis right here, positive on the Z. So if the camera’s back here, we’re looking towards positive Z and that is the forward direction which we’re gonna be then using later on in order to move the player around.

Okay and let’s rotate the camera because the camera’s facing the wrong way. So we’ll set on the rotation degrees on the Y to 180. There we go, the camera is now flipped. And if you wanna have a preview of what this looks like, we can just go up here to preview, click that box, and there we go. This is what we gonna be seeing by default. This is what our camera sees pretty much. So pretty much from here, that’s the camera set up.

The script that we’re gonna be creating later on, it won’t be attached to the camera but it will be attached to the camera orbit. So we’ll be able to then modify the rotation degrees on the Y, here for example. And we can’t really see it here on the Y, but on the X for example, you’ll see that we can rotate it up and down and this camera then orbits around the player pretty easily. We don’t have to worry about modifying the position of the camera. We just need to rotate the camera orbit object.

So I’m just gonna untick preview here so we get out that and now what we need to do is set up our weapon, ’cause the player’s gonna be holding a sword. So in order to do that let’s go ahead and I’m gonna create an empty object first of all because we need a weapon holder that’s gonna hold the sword model and the weapon holder is gonna be what also is animated rather than animating the actual model, as since the model, we’ll probably have to scale it down a bit. So working with position, working with like translation and rotations when you have uniformed scales isn’t really the best thing to do.

So let’s go create a new child node player, create new spatial here. I’m gonna call this one our weapon holder and I’m gonna move this over to the player’s right arm. You can of course choose left or right arm. So in transform, I’m gonna set the translation to negative 0.58 on the X, one on the Y. And just to make it go out of the player’s body a bit we’re gonna make it 0.035 on the Z here so it goes forward just a tiny bit. Okay, so there we go. We got the sword holder or the weapon holder.

Now what we can do is go to our model’s folder and then you’ll see that we have a sword.dae right here. Now dae, this is pretty much very similar to the .fbx model format if you have used that before. But the benefit with dae is that it’s open-source. So it works with Godot by default. So we can just drag this in like so and as you can see our sword is very large. Make sure it is a child of the weapon holder here.

And what we need to do, first of all, is set the position here to be zero, zero, zero. And of course, it is very large so what we need to do is scale it down. So I’m gonna set the scale to be 0.15, 0.15, 0.15. There we go, that’s about the right size and we just need to rotate it now. So I gonna set the rotation degrees on the Y to be 90 and let’s have it at a bit of an angle. So 45 on the Z. So it looks like that and click on our camera again and check out the preview to see how it looks. There we go. We’ve got a player with the sword. We can unpreview now.

All right so we got all of our objects here pretty much set up and ready to go. We’ve got our sword, we’ve got our camera, we’ve got our player model. Finally, what we need to do is add in the attack raycast which is going to be basically how we detect if we’re looking at an enemy when we attack them.

So I’m gonna add in a new node here and this is going to be a raycast node. Now if you don’t know what a raycast is, think of it as a sort of a way to see what is in front of us or what is in a certain direction. Because with a raycast, you give it a position, then you give it a direction to go towards and what it does, is it pretty much shoots a little point from one position in a certain direction, and pretty much if it hits something, it’ll return information on that. So think of it sort of as a gun for example.

In fact, many games use raycast for their guns. When you shoot a gun it goes and the bullet goes along from the muzzle in the direction it is facing. And if it hits something, it gets detected pretty much. We can then get information back of what we hit and in our case, we’re gonna be checking to see if we hit an enemy.

So we’ve got our raycast here, I’m just gonna rename this to attack raycast. And I’m gonna to set the transform translation here, the position to be negative 0.3, 1.6 right here. So it is sort of in the middle of the player but a little bit over towards the sword because we don’t want to be able to hit an enemy that’s not really in line with the sword. And you can see this white line right here and this white line pretty much shows how far our raycast is gonna go. So pretty much anything that intersects this white line right here will be detected by the raycast.

So I’m gonna click enabled up here. Otherwise, it won’t be working and we wanna change the cast too. So it is gonna be facing in our forward direction here, not down. So keep X on zero, we’ll set Y to zero and we’ll set Z to be 1.5. There we go. We can now have the line pointing out this direction from our player. So pretty much whenever there’s an enemy inside of this line right here and we attack them that damage will be dealt to them.

All right so that is pretty much it. We got everything here set up and ready to go. Now if we go back to the main scene, what we can do is in fact go ahead and drag in our enemy so go to the file system, drag an instance of the player. I’m gonna set their position to be zero, zero, zero so they’re right in the middle of the level. And there we go. We can see that the player’s in the level, they look about to scale. We might actually need to move them up a bit, ’cause it seems like they’re clipping into the ground. We’ll move them up to 0.3 high so their sitting on the surface.

And yeah, now what we can do is press play and see how it looks. And there we go, we’ve got our player in the scene, but of course we don’t have the ability to move the camera around or move the player around. We’ll be working on that in the next lesson.

Camera Setup

Welcome back everyone. In this lesson, we’re gonna begin to actually set up a camera look. Have the ability for a camera to orbit around our player when we move the mouse around.

So, we got a player scene right here inside of the main scene. So what we’re gonna do is go over to the player scene, select a camera orbit object which is the empty spatial node which has the camera as a child of it. We’re gonna go to our camera orbit and we’re gonna create a new script. This one is gonna be called a camera orbit right here. CaremaOrbit.gd All right so here we are inside of the script. I’m just gonna remove these default templates right here.

So first of all, we’re gonna begin with our variables, okay. First up, we have look sensitivity. So variable lookSensitivity and this is going to be a float and by default will equal 15. Now, lookSensitivity is just gonna be basically how fast this the camera gonna rotate based on how fast our mouse moves. All right, then we need a minLookAngle. This is gonna be a float and we’ll have equal negative 20.0 by default.

Now the minLookAngle is pretty much how far down can the camera rotate because, we don’t wanna be able to rotate the camera all 360 degrees around the play because otherwise, that will cause issues with how the camera orbits around it’ll just be very disorienting for the player so we’re gonna sort of clump the vertical rotation of the camera. along with min, we also need a maxLookAngle of type float and this will equal 75. So how far up can the camera rotate.

All right, that’s the main three main variables done. Now what we need to do is keep track of the mouse delta and the mouse delta is pretty much each frame, how fast and in what direction did the mouse move? So we have var, mouseDelta and this is gonna be of type, Vector2 for an X and Y in screen coordinates and we’ll just have this default equal an empty Vector2.

Now, we just need to get the player object and the reason why is because, when we rotating the camera around, we’re gonna be rotating the camera orbit object up and down so we can look above the player, we can look towards more horizontally along the player. But when we rotate sideways, whenever we want the player to rotate around its y-axis, we’re not gonna actually be rotating the camera instead, we’re going to be rotating the player.

And the reason why is because, later on, once we get into moving the player around, instead of having to figure out which direction the player is facing and then get that based off its current direction, all we’re gonna do is just get whatever direction the players looking forward in and move based on that. That’s gonna make it a lot simpler for us.

So I’m also gonna go down here and go, var player and this is gonna be an onready variable so once the game has started and this node is initialized, we are going to get_parent which will just get the parent node of this one. So the parent node of camera orbit is the player kinematicbody node. That’s their variables there.

Now, let’s set up a function that gets us this mouseDelta ’cause how we can actually figure out how fast and in what direction our mouse has moved each frame. Well, we can do that inside of the _input function. So func_input. You should see that it automatically pops up with something here we can hit enter on and this is a function that is built into Godot and this event here it just contains all the information of whatever’s being pressed down, whatever’s being happening based on your keyboard, your mouse or any other controllers you have that frame.

So, what we’re going to do here is, we are going to set mouseDelta whenever we move a mouse. So to check if we’ve moved our mouse, we can go, if event is InputEventMouseMotion. So if we have moved the mouse around this frame, then we can just go mouseDelta equals event.relative and there we go. It’s as easy as that. Just two lines of code and so each frame when we move our mouse around, this vector here will be filled in and then inside of the process function which we can go ahead and create now, func_process, creates automatically with a delta parameter.

This function gets called every single frame so if the game is running at 60 FPS, this will be called 60 times a second. And Delta here, this parameter, is basically the duration between each frame and we use this in order to do stuff based on per second rather than per frame which just makes it Framerate independent, nothing’s tied to the Framerate then. So what we want to do here is get the rotation pretty much.

What rotation are we gonna be applying to the camera and the player? So we go var rot equals and this is gonna be a new vector3 because we’re gonna be rotating around the X and the Y value but not the Z because, Z is sort of tilting sideways but we still need that included here, we’ll just have it at zero. So for the X, this is gonna be mouseDelta.y because, if we’re moving if a rotating along the x-axis that is gonna rotate the camera up and down so that’s gonna be mouse movement up and down. And then horizontally, that’s going to be X. So, mouseDelta.x and zero for the Z. Now, we just need to multiply this by the lookSensitivity and multiply it by delta as well And multiplying it by delta just gives us a bit of a smoother camera rotation.

Okay, so we’ve got that rotation variable there set up. Now, we need to apply this rotation to the camera and to the player. So first up, we’re gonna apply the vertical rotation. This is the rotation when we move the mouse up and down. It’s gonna be rotating the camera orbit object to look above the player and below the player. So, what we’re gonna do is just go rotation_degrees.x plus equals rot.x. Ops, don’t need any of that being there, .X.

Now we can do that but if we keep moving our mouse up, it’s gonna eventually do a loop around the player but we don’t want that. We wanna clamp this position. We wanna clamp the rotation around the player. So to do that we can go, rotation_degrees.x equals and then we can do something known as the clamp function. And the clamp function is really handy because we can give it a three values. We give it a value that we wanna clamp which is going to be the rotation_degrees.X and then we give it a minimum and a maximum value. And pretty much it’s gonna make sure that this value that we’ve given it stays in between the minimum and the maximum given values.

So a min is gonna be our minLookAngle and max is gonna to be our maxLookAngle as well. So we’re rotating the camera vertically now.

What we need to do then is, rotate the player horizontally because when we rotate camera sideways, we’re not gonna be rotating the camera or the object, we’re gonna be rotating the entire player. So for that, we can just go a player.rotation_ degrees.y and then this is just gonna be minus equals rot.y. All right, now the reason why we’re not gonna be clamping this value is because, if we’re rotating sideways, there’s no real limit that we can go. We can go 360 degrees around as much as we want really because there is no limit that we’re gonna reach.

And finally, we just need to clear the mouseDelta. So mouseDelta equals Vector2 and this just is so that, if we stop moving our mouse, we don’t keep rotating around in the same direction. Okay so we’ve got all this set up. We’re getting the mouseDelta, we’re getting the relative input which is basically how fast and in what direction the mouse has moved each frame. Then, we’re getting the rotation so we’re getting the X and the Y multiplying that by our look speed and then by Delta. And then down here, we’re rotating the player, rotating the camera here, up and down and then we’re rotating the player sideways and then we’re clearing the mouseDelta.

So, let’s go ahead, we’ll press play and see if this works. All right we’ve got our play here. Let’s move our mouse around. If I move left to right, you’ll see that our player is moving around and if I move up and down, you see that just the camera is moving and that’s what we want. You can, of course, tweak this to however you want, if you want the camera to move independently of the player as well. So, if you want the horizontal camera to only rotate the camera and not the player, you can of course do that but we’re just gonna have a like this for now.

You might also notice something here, is that, the mouse is still here. So if we go off screen, you’ll see that the mouse no longer rotates the player so when we’re moving around, it might be a bit annoying to work with that. So what we can do is basically lock the mouse cursor. So at the start of the game, this mouse is hidden and it is locked to the screen which is really what you want for these games that control the camera with the mouse.

So we’re gonna to do that inside of the _ready function which gets called once when the node is initialized so right at the start of the game. And what we want to do here is, hide the mouse cursor. So I’m gonna go Input.set_mouse_mode and the mode we wanna set to this mouse, you’ll see that there’s four different ones right here. Visible is what we have right now and the mouse is visible we can see it. Hidden is when the mouse is hidden on screen but it can still move around. Confined is when it is pretty much confined to the screen but we can still see it. And captured is when it’s confined to the screen but it is also hidden and that’s what we want. So we got mouse mode captured here.

Let’s press play and you should see now that the mouse is no longer appearing on the screen so we can move around as much as we want and the mouse isn’t going to fall off the screen. All right, great. But one thing you may notice is that, you can’t click on the X now to get out of this. Escape doesn’t work, nothing works. So to get out of this, we can just go Alt+F4 which will quit the window right here and will turn us back to the editor.

Now, in the next lesson, we’re gonna go on and actually start scripting our player, setting up the player movement and some of their other functions so we can start platforming our player, jumping around and later on, start attacking enemies. So thanks for watching and I’ll see you in the next lesson.

Input & Player Script

Welcome back everyone. In this lesson we’re gonna begin to script our player. Have the ability to move around with the WASD keys, jump with the space bar and yeah. From there we’ll then move on to attacking and collecting coins.

So to begin, what we need to do is set up our actions because whenever our player wants to move, we need to know which keys on the keyboard do what things. What do we need to press in order to move forward, back, left, right, jump. So, let’s go over to the Project button up here. Then go Project Settings. And in here we want to go to the Input Map tab. And we’re gonna create some actions. An action can be a key press, a mouse-button click or anything with a joystick controller, stuff like that.

So, we’re gonna make a few actions here. We’re gonna have move_forward. Press enter to create a new action. move_backward, move_left, move_right. And then we’re gonna have jump and attack. Okay, so we got our six new actions over here. And what we’re gonna do is click on the plus icon for move_forward here. We’ll go Key because this is gonna be a keyboard key. And then we can just enter in the key that we want. So I’m just gonna press W. There we go, hit OK. And move_forward is now assigned to W. We can do move backward here to S. move_left can be A. move_right can be D. jump can be space. And for attack this is gonna be a mouse button. So we’re gonna go Mouse Button. And then Mouse Button Index is gonna be left mouse here.

And we’ll just set the Device to All Devices, just to make sure. Because by default it’s set to Device 0. Although that may not work if there’s some problem with how it’s connected. So we’ll just set All Devices, and there we go. All right, we can close out of that.

Now in our player scene, let’s go ahead select our player node right here. I’m gonna create a new script, which is gonna be called Player.gd. We can remove this base template stuff here. And what we’re gonna do is begin with our variables.

So, first up we need to know our current HP. That’s gonna to be of type int. And we’ll have that equal to 10 by default. Then our maxHP, which is gonna be the max amount of HP we can get. And we’ll have that 10 as well. Then we all know how much damage we do. So whenever we attack an enemy, how much damage are we gonna be dealing to them? We’ll have an int and we’ll have that as one by default. Later on we’re gonna implement gold so we can collect coins. So we’ll have gold, int equals zero.

And then we also need to know for attacking, how often can we attack? What’s the minimum amount of time between clicks are we allowed to attack? That’s gonna to be our attackRate of type float. And we’ll have this equal 0.3. So every .3 seconds we can attack again. And this is gonna be tied to the length of our animation. We also need to know that the lastAttackTime. And the lastAttackTime here is just going to be in terms of milliseconds from when we last attacked. And we’re gonna be getting that from looking at our computer’s current time. We’ll be doing all that later on. But, we’ll just have the variable here for now. int equals zero.

And after this, we needed to get on with some of the physics stuff. So, first of all, our moveSpeed. Which is gonna be a float. We’ll have this equal 5.0. So, we’re gonna be moving 5.0 meters per second. Then we have jumpForce. So how much force is gonna be applied upwards when we press the space bar to jump. This will be a float and it will equal 10. And after this we also need to know gravity because we are gonna have gravity being applied to us. This is gonna be of type float. And we’ll have this at 15.0. So we’ve got that, we’ve got our gravity.

Now let’s also create a variable which is gonna be a Vector3. We’ll call it vel for velocity. Of type Vector3 equals a new Vector3. And velocity is just gonna be our basic velocity. Where are we moving, which direction and at what sort of speed. So we need to keep track of that.

And finally some of our components. We need to know the camera and the attack raycast. So, for the camera this will be an onready var because we are gonna be getting this when the node is initialized. Camera equals get_node. And we want to get the CameraOrbit object, which holds our camera script. Okay, so we got the camera. Then we need to get the attack cast. So let’s go var attackRayCast here equals get_node. And we need to get the attackRayCast right here. That’s all our variables set up and ready to go.

Now what we can do is start on actually moving the play around inside of the physics process function. Now the physics process function is a function which gets called 60 times a second. It’s different to the normal process function, which gets called every frame. And this is just in order to maintain consistency with physics. So if you working on of anything with physics such as what we’re doing right here. It’s good to do that in the physics process function.

So, we can here go func _physics_process. It’s built into Godo. And delta here is the time between each frame. So, what we want to do here, first of all, is set our x and z velocity to zero. Because when we’re not clicking a button, we don’t want to keep moving, we want to pretty much stop moving straight away. So vel.x equals zero. And vel.z equals zero as well. And then after this, we wanna be able to get our input vector. And the input vector is gonna be filled in whenever we press on a button, WASD. So, this is gonna be pretty much a vector that gets the input and then we’ll be applying that to our velocity,and modify it a bit later on. So, var input equals Vector3.

And now we need to check each of our key presses. So, if an action is pressed, the move forwards, backwards, left or right action, we need to modify this input vector right here. So, we can go if Input.is_action_pressed. And the action here is gonna be move_forward. Then what we’re going to do is go input.z += 1. So we’re moving forward. So we need to increase z here by one. So z would then be, so the input vector would then be 001. If we wanna move backwards. So we do the same thing here. If Input.is_action_pressed. And that will be the move_backward. Then we just wanna go input.z -= 1.

Now I’m just gonna copy and paste this right here. Paste it down like so. Also remember to put the colon at the end of a statement. We’ll replace these ones with x. And move backwards with move_left and move_right. So there we go. We’re getting all of the axes right here to be assigned to the input vector right now. And what we can do now is normalize this vector.

Now what normalizing the vector does is makes it so that we don’t move faster horizontally. Because if you think about it, the magnitude of this vector here, which is pretty much all the three axes added together. So x, y, and z added together. If we’re moving forward, our input vector here is going to be 001. So the magnitude is gonna be one. If we’re moving horizontally, the z is gonna be one and the x is gonna be one. So the magnitude of that is gonna be two. So we’re gonna move twice the speed if we move diagonally. So we wanna prevent that. So if we’re moving diagonally, then our forward and right speed will be halved. So to do that, we can just go input equals input.normalized, like so. Okay, so we’re normalizing the value.

Now what we need to do is figure out which direction we are facing. And the reason why is because when we press left or right whenever we wanna move in a certain direction, we don’t want to move based on the global direction. So if we’re looking straight and we press forward, we’ll move forward. But if we then rotate 90 degrees and we press forward, we’ll start moving left. So we don’t want that. We wanna move based on the direction we’re looking. So for that we need to figure out which direction we’re looking in.

So go var dir. And this will be equal to, and in brackets here I’m gonna go transform.basis.z. Which is our forward direction, our local four direction. Multiplied by input.z. Plus transform.basis.x. Which is our right direction. Multiplied by input.x. And there we go, that is our direction right here. It is a Vector3 as well. So what we need to do now with this, is set our velocity on the x and z axes. So, here we can just go vel.x equals dir.x multiplied by moveSpeed. And then vel.z equals dir.z multiplied by moveSpeed, there we go. So now what we’re doing is we are assigning our velocity to be the correct direction and the correct speed.

Now next up, we need to work on implementing gravity. And that is gonna be worked on in the next lesson. So in the next lesson we’ll implement gravity, we’ll implement jumping. And this will then allow us to create a basic platform character for our game. So we can move around, we can jump, we can look around. All that good stuff. So see you all then in the next lesson.

Gravity, Jumping, & More

Welcome back, everyone. In the previous lesson, we began to create our player script right here. We set up our variables. Then, we went ahead and started implementing the player movement, so we got the key inputs right here. We then normalize any input, so we don’t move faster diagonally. Then, we’re calculating our local direction in which we’re gonna be moving in. And then, we are basically setting up a velocity right here, so it has the appropriate move speed. Now, in this lesson, to finish off the movement, we’re gonna be implementing gravity and jumping, and then, finally, actually moving the player along that velocity.

So first up, let’s start with gravity. So for gravity, all we need to do is modify the y velocity, so the vertical velocity of the player. So here, I’m just gonna go vel.y minus equals gravity, and then, we need to multiply that by the delta, which is basically the duration between two frames since the physics process function here does get called 60 times a second. And this here is basically going to increase the gravity over time, so if we fall from a high height, we’re gonna speed up as we move downwards. All right, so we got our gravity. Now, I’m just gonna leave a comment here.

And next up, we are going to implement the ability to jump because we have the jump inputs, so let’s now detect for when we press the jump button. So we can go if Inputs.is_action_pressed and the action we’re gonna be checking for is jump. Then, what we’re gonna do is we are going to just set our y velocity to be the jump force, so vel.y equals jumpforce. And then, we can also implement a little comment here that just says jump input.

Okay, so we got this here, so whenever we press the Space button, we’re gonna be jumping, but one problem is that as long as we have the Space button held down, we’re gonna continuously be setting our y velocity here, and that’s not what we want. We wanna make it so that only when we’re standing on the ground can we jump. So in order to do that, we could do some complex maths with raycast and all that, but since we are using a kinematic body node right here, what this allows us to do is just have one function call to see if we’re on the floor.

So we can go if Input.is_action_pressed jump and is_on_floor, which is a function in the kinematic body node, this basically just tells us yes or no for whether or not we’re standing on the floor. So if we’re standing on the floor and we press the jump button, then we’re gonna set our y velocity. Okay, we got that.

Now, finally, what we can do is modify our velocity overtime, move the player. So in order to do that, I’m just gonna leave a comment here, move along the current velocity. We’re gonna be using a function that also comes with the kinematic body and this allows us to move the body along a certain velocity, and also detect collisions and also detect which way the floor is facing. So that can also tie in with checking to see then if we’re standing on the floor. And overall, this is probably the best way to do player movement if you want to have a physics-based character that can jump, that can land on platforms, that can detect when they’re on the ground.

So for this, we’re just gonna go vel equals, and the reasons why we’re doing equals is because this function returns a velocity, which is always good to put back into the velocity right here. So vel equals move_and_slide, and then, what we’re gonna be giving it is our velocity, so we’ll just go vel. And then, optionally, we can give it some other things and we wanna give it the up direction. And the up direction is basically which way is the ground facing. So since our ground is facing is on your feet, the ground is gonna be facing upwards. So we can give it a vector for that. I’m just gonna go vector3.UP, which is a prebuilt vector in Godot here, which is zero on the x, one on the y, and zero on the z, and that’s pretty much it.

So what we can do now is press play and we should be able to look around with our camera just like before, but now when we use the WASD keys, we can move left, we can move right, back, and forwards. We can jump with Space, and as you can see, if we spam Space, we don’t jump until we land on the ground. Let’s go try some platforming. There we go, and wherever we are looking is the direction that our forward direction is in, as you can see, which is really good. So overall, from here, this is the play controller set up and complete.

You can, of course, add in many more features, tweak it to be a bit better maybe. We want some smoothing of when the player starts moving, stuff like that, but overall, if you just want a play controller that you can easily chuck in a game and 100% work, then this is a good way to go. So go Alt + F4 to quit out the game, and yeah, so let’s just go over real quick of what we’ve been doing right here. On our player script, we set up our variables here.

Now, not all of them are being used right now. Many of them, such as gold and attackRate, stuff like that, is what we’re gonna be using later on once we implement those functions. But we’ve got the main physics process function here, which gets called 60 times a second, which is really good if you want to do some physics-based app coding. We’re initially setting our x and z velocity to zero, so that we don’t just press the left button and we keep moving left even when we’re not pressing it. Then, we’re creating an input vector which is what is used to detect the inputs from the keyboard. So when we press the move forward button, we’re setting the z to be plus one, when we move backwards, negative one, left, right, we’re setting the x value.

Now, with the input, we’re normalizing it because if we hold, let’s just say, W and D, we’re gonna move forwards and right at a faster speed since the magnitude of that velocity is gonna be two rather than just one if we’re moving in just a single direction. So we’re making it here, that when we move diagonally, we’re gonna be moving at the same speed as if we’re just moving in one direction.

Then, down here, we’re getting the relative direction, so we’re basically getting the forward direction, multiplying that by the forward input. Then, we’re getting the right direction and multiplying that by the right input to get us our local relative direction to wherever we’re facing in the world. Over here then, we are setting our x and our z velocity to be our direction property over here, multiplied by the move speed, so we can have a varied move speed.

Then, we’re setting our gravity, so overtime, we are basically decreasing our y velocity over time, so that we fall. And multiplying that by delta here just makes it so that the gravity isn’t instantly super fast. We’re moving in gravity here, basically, per second squared, so if we go up here, look at our gravity, it’s 15.

Now, in real life, gravity is about 9.5, I believe, and the reason why it is so high is because, in video games, a low gravity that is close to Earth’s doesn’t really feel that natural. It doesn’t actually feel that real because in video games, you’re normally jumping at much greater heights as you would in real life and falling from much greater heights. So if you would have a real-life sort of gravity, then it would actually feel really slow. Many games have a gravity of around 15 or even high up to 20 just ’cause it feels much more natural for video games.

Okay, then down here in the jump input, we’re detecting for when we press Space bar or the jump action right here. Then, we’re checking to see if we’re standing on the floor. If so, we’re setting the y velocity to be jump force, so we’re instantly shooting up into the air. And then, if we’re no longer pressing Space, gravity is gonna be taking over from there.

And finally, with all that stuff set up and going, we’re gonna be setting our velocity to the move_and_slide function, which is gonna move us along that velocity, keeping in mind that the up direction is where the floor is, so it can detect stuff, such as if we’re standing on the floor and if we’re gonna be hitting anything, so that we don’t go through collides. We bump into them and stop moving. And that, overall, is the movement here set up and done.

In the next lesson, we’re gonna be starting to begin implementing gold coins, so we have something to collect, and we’re then gonna be creating functions here on the player, which can also then tick up whenever we got the gold coin. And then, later on, when we create a UI system, our current gold amount will be displayed on screen. So thanks for watching and I’ll see you all in the next lesson.

 

Interested in continuing? Check out the full Develop a 3D Action RPG with Godot course, which is part of our Godot Game Development Mini-Degree.

]]>
Free eBook – Godot Game Development for Beginners https://gamedevacademy.org/free-ebook-godot-game-development/ Wed, 01 Jul 2020 08:09:57 +0000 https://godottutorials.pro/?p=3566 Read more]]> We’re overjoyed to bring you our latest eBook: Godot Game Development for Beginners.

With tutorials created by experienced game developer Daniel Buckley, this eBook will set you on an exciting path of 2D and 3D game development with the open-source Godot game engine.  You’ll learn to create platformers, RPGs, first-person shooters, and more as you dive into various mechanics and the engine’s personal scripting language, GDScript.

By the end, you will have gained in-demand skills for shooting mechanics, raycasting, level set up, player controllers, and more – all of which can be expanded and applied to your own game projects!

Download the eBook here

 

]]>