avatarMina Pêcheux

Summarize

A short beginner’s guide to discovering Godot 4

Wondering how to dive in this nice free & open-source engine? Learn the basics with this getting-started guide!

With everyone looking for alternatives to Unity after their new “fee” announcement, and considering Godot, thought I’d make a little “getting started” bouncy ball tutorial… I hope it can help some game devs with the transition, and help people discover this really cool free open-source game engine :)

So if this is your first time in Godot and you want to understand the basics of this game engine with a basic bouncy ball demo, then this tutorial is for you!

By the end of this article, you’ll know how to create some simple 3D meshes, setup a camera and a light and even add a bit of physics to have your objects interact.

As usual, don’t forget that you can get the demo scene and all the assets from this demo on my Github 🚀 with all my other Godot tutorials.

The tutorial is also available as a video — text version is below:

And, on that note, time to dive in and take our first steps in Godot :)

Install & setup

Alright — first of all, of course, we need to download the software. So just head over to Godot’s website, to the Download section, and pick the version that matches your OS.

You’ll notice that there are two variations: either with or without .NET. Basically, .NET support is useful if you plan on doing C# in Godot — which can be more efficient than using an interpreted language like GDScript, but can be a bit tougher to learn if you’re not familiar with it yet :)

Anyway, let’s say you go for the basic version — once it’s downloaded, just unzip the archive and you’ve got Godot on your computer! I’m on Mac, so I just need to drag and drop this executable in my Applications folder, and I see it’s readily available.

Now, let’s open up the engine and see how it works.

When Godot starts up, it will show you a panel to pick or create a new project.

Pretty standard stuff, but a pretty cool feature is that you can actually define your own tags on your projects, and then simply search by this tag in your list if you’re looking for specific projects :)

Anyway, to open one, just double-click on it, and the actual editor will then open up with your project loaded in.

For now, of course, our project is completely empty, except for the little Godot icon that is imported by default. So the next step is to learn how to create 3D scenes with meshes inside!

Creating & populating 3D scenes

To start off, let’s take care of making our red ball object.

Ok, now — in order to create a new scene, we need to go to the Hierarchy panel in the top-left corner and choose one of the possible node types for the root:

The node is the core entity in Godot: it’s a little piece of scene that can hold a more or less complex component and participates to the logic, the visuals, the physics, etc.

The “Node” is the simplest type but of course, you also have a long list of built-in node types that already have useful components and can be mixed-and-matched to build your own behaviours.

The engine sorts these node types in three categories: 2D, 3D and UI. Each category also has its own colour, so:

  • whenever you see blue, it’s 2D
  • whenever you see red, it’s 3D
  • whenever you see green, it’s UI

Here, let’s stick with 3D — so we’ll go for a simple Node3D root element.

If you look on the right, in the Inspector, you see that this base 3D node type has very few properties — it’s simply a 3D transform that you can show or hide.

So, to really visualise things and make our red ball, we have two solutions:

  1. either we change the type of this root node to pick a more evolved type, that includes a mesh renderer,
  2. or we create a new child node under it to handle this mesh.

Usually, I prefer to keep a basic root node at the top and then have child nodes handle the visuals or the logic. I feel like it gives you more room to adjust offsets, re-arrange the hierarchy and overall maintain your objects.

So let’s right-click on our root and add a new child node. Here, I’ll use the search bar to find the MeshInstance3D node type. I can double-click on it to create a new instance as a child of my root in the scene.

Except that, as you can see — or, rather, can’t see — , we still don’t see anything!

The thing is that, in Godot, like in all game engines, most components require resources to function properly — for example, a mesh renderer needs mesh data to actually know what to render. You can of course import some complex model from Blender, but you can also create basic shapes directly in Godot — and more precisely: directly inside your component.

If you click on the <empty> value in the Mesh property in the Inspector of the new node, you see that you get a dropdown with various options: the top of the list allows you to create new mesh data resource on-the-fly, if you just need simple shapes, and the last options let you load a 3D model file if need be.

Here, let’s choose the SphereMesh option. You see we do get a visual in our scene — and the interesting thing is that our resource is directly linked to our component, and editable inside its Inspector.

So we finally have a sphere, that’s cool!

However, this white colour is not great: we want to make it red. Again, it’s just a matter of creating the right resource in the right place. And, this time… we actually want to create a material resource inside our new mesh data resource!

We can do so by opening the Surface Material Override section, and again creating a new resource. Here, we’ll use a StandardMaterial3D. So we now have a material resource inside our SphereMesh resource, and we can open its sub-inspector to change its colour to red, in the Albedo sub-section.

Now, depending on which game engines you used before, if any, this idea of “embedding” inspectors inside one other might be a bit strange but, trust me — you quickly get used to it, and it’s a real time-saver when you start to have a lot of files in your project cause everything ends up being localised in a neat context ;)

Anyhow, at this point, we’ve prepared our basic red ball. So, should we just keep building our whole scene around this? Well, in fact, a better solution is to just turn this ball into a single prefab, and then re-use it in a larger scene. This way, if we decide to add multiple balls, and wanna change something, we’ll just have to update this reference model and all the instances will get synced up.

If you come from Unity game dev, you might be thinking that we need to explicitly create a new asset in our project based on our hierarchy to make it a prefab. But Godot really makes it simpler… See this scene hierarchy we made? That’s a prefab. Yep, that simple.

So basically, just by saving our scene in our project, we get a re-instantiable hierarchy, just like a Unity prefab.

With this red ball ready, let’s see how to setup our bigger scene and instantiate our brand new prefab inside it!

Setting up a “bigger” scene

To get a new fresh scene, let’s go to the Scene menu at the top and click on New Scene.

You see this brings us back to a new empty hierarchy, where we can pick the type of root node we want. We’ll once again make a 3D scene — and something I like to do is double-click this node to rename it to “Root”. Having conventions like this can be very helpful when you start to code and want to find nodes by name.

In this scene, we know that we want a simple plane for our ball to bounce off of, and an instance of our ball scene from the previous section.

  • To make the ground, we can once again use a MeshInstance3D node, give it a PlaneMesh shape and leave it with the default white material.
  • Then, to add our ball to the scene, we just have to drag it from the FileSystem dock in the bottom-left corner, and drop it in the hierarchy.

And tadaa! We have our two objects properly mixed in a new scene.

If we want to try and run our game, we can simply click the play icon in the top-right corner of the screen.

Godot will ask us if we want to define this scene as the main one, to run by default, so let’s accept, and then the engine will open a popup window with our very basic scene inside.

The problem is that of course, we can’t see anything because we don’t have a camera, nor light.

So let’s close this popup and add two new nodes to our 3D root node: a Camera3D and a DirectionalLight3D.

For the light, I’ll bring it out of the origin and have it point at my object from the front, slightly above, for example. For the camera, to make sure I get an okay view, a good trick is to do the following:

  1. Go to the View menu in the Viewport panel
  2. Split the viewport in 2 horizontally
  3. Select the camera node in the hierarchy and in the bottom half of the Viewport, click on Preview in the top-left corner

This bottom view now shows us what our camera sees — which, for now, is nothing.

Let’s bring our camera back and slightly up. To get a better result, we can change the FOV parameter of our camera to a lower value, like 30 for example. Also, note that if you want to translate the camera in local space instead of global space, typically to move according to its current orientation, you can press <T> or click this little button.

If we run this again, that’s it — we see our white ground and the red ball laying on it!

Last but not least, let’s quickly discuss how to add some physics to our objects so that the ball falls and bounces off the white plane :)

Adding some physics

Ok — to begin with, let’s make sure that our ball falls down thanks to gravity. To do this, we can go to our Hierarchy and, in the row of the node instance of our Ball scene, click on the icon of a scene with a triangle:

This directly opens the reference scene that instances comes from, and it avoids us having to search in our project directories for the right file ;)

If you’re somewhat familiar with physics, you probably know that, in order to get a 3D object moving thanks to auto-physics, you usually need two element:

  • a rigid body to compute the forces and make the object move
  • a collider to have the object interact with and be blocked by the other objects in the scene

In Godot, there are two node types for this (in the case of 3D): the RigidBody3D and the CollisionShape3D.

Let’s add both to our Ball scene:

You’ll notice that, as-is, Godot shows us warnings next to our physics-related nodes. And the message indicates that, basically, we need to parent the collision shape to the rigidbody to have them work properly:

So that’s how it works in Godot: whenever you do physics, you need to give the physics body node first and then, inside, as a child node, the shape of this physics element:

And, of course, don’t forget to actually define a shape inside the CollisionShape3D component by making another on-the-fly resource — here we can take the SphereShape3D type:

Ok — let’s save this, and then go back to the tab with our main scene at the top.

Obviously, we don’t actually see any visual changes; but we can go to our hierarchy and right-click on the Ball scene instance to toggle on the Editable Children option — this shows us the content of the instantiated scene and we do see that we have our new physics-related child nodes.

Great, so let’s test this, right? Well… if we launch this, the sphere doesn’t actually move!

But why? Rigidbodies are subjected to gravity by default, so what’s the matter?

The issue lies in our Ball hierarchy. For now, we naively stacked all of our child nodes next to each other: the mesh and the rigidbody are siblings. So what’s actually happening without us knowing is that the rigidbody is indeed falling… but the visual mesh isn’t hooked to it and doesn’t follow!

To solve this, we just need to take our mesh node and drag it under the rigidbody:

If we restart the game, it works!

The ball is now falling — but, of course, it’s going through the ground plane, because this plane doesn’t have any physics component yet :)

We basically need to do the same thing for the ground, except that this time we’ll use a StaticBody3D instead of a RigidBody3D because this plane shouldn’t move — it will only be used as a static collider to stop the ball. The rest of the steps is the same: parent to the collision shape to the body, define a shape inside this component and finally adjust its size to match the visual mesh.

If we restart the game, we see the ball indeed gets stopped by the ground — pretty cool!

A last little improvement we can make is make the ground bouncy, cause for now this sudden stop is really harsh on the eyes.

To do this, the trick is to do as follows:

  • First, we right-click in our FileSystem dock to create a new resource. More precisely, we want to make a new PhysicsMaterial.
  • Then, we can click on it to show its Inspector, and up the Bounce parameter to at least 0.7.
  • Finally, we just have to click on our ground static body and drag the physics material to its Physics Material Override slot.

And there we are! Once we restart the game, we see that the ball now falls down, bounces on the ground a few times, and eventually loses energy…

Conclusion

So here you go: you know how to setup a basic 3D scene in Godot, and even how to add some physics!

I hope you liked this tutorial and that it helped you navigate the Godot editor if you’re still a bit new to it. If you did, feel free to clap for the article and follow me to not miss the next ones — and of course, don’t hesitate to drop a comment with ideas of Godot tricks that you’d like to learn!

As always, thanks a lot for reading, and take care :)

To read more of my content, and articles from many other great writers from Medium, consider becoming a member! Your membership fee directly supports the writers you read.

Godot
Godot Engine
Game Development
Tutorial
Beginner
Recommended from ReadMedium