Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 13

Exploring The Editor

In this lecture, we are going to understand the six key parts of the editor and get set
up.
Making our first scene.
So now we are in the Godot engine editor proper.
It is worth knowing what all the key regions of this window are.
So the first big thing you'll see is in the middle, this big square here is the viewport.
This gives us a view into either our 2D world, our 3D world, or our scripts, depending
on what mode
we have selected.
By default we will see our 3D world, which is this big grid with these axes showing us
our world's
orientation.
And if we click in our middle mouse button and move the mouse around this
viewport, you'll see it rotates
our view around in 3D space.
Following that, we have the top bar which has three key parts.
We have all of these menu buttons where we can set up projects and editor settings
and the like on the
left.
Playback controls on the right for running our game.
Once it's set up, and in the middle we have our main screen buttons.
This is how you change between those different views I was describing earlier.
So the 3D main screen button is highlighted at the moment because we're in our 3D
view.
But if we click on the 2D button, we change to a view of our 2D world which doesn't
have any depth.
And you can see it's got a gray background and we can move around that in the same
way as I was rotating
in 3D.
By clicking the middle mouse button in and moving the mouse around.
We also have a script button and an asset library button, but these won't show us
anything important
at the moment.
We don't have any scripts in the scripts tab yet, and we are not interested in
downloading any assets
from the asset library.
So return to the 3D view.
In the previous lecture we had a close look at the file system.
The file system is where all of the files we add into our project go.
It will contain things like audio files or meshes for 3D models, and it will also contain
scenes we've
created in our game later on.
In the top left we have our scene tree and our scene tree.
We need to know a bit more about how scenes and nodes work in Godot before we
can fully understand that.
So Godot games are fundamentally made out of scenes.
A scene could be your player character, or the level they're in, or an enemy or
something controlling
the camera.
We make these scenes out of smaller building blocks that all do specific tasks, and
they're called
nodes.
So you could have a node that was a 3D model, or a node that was a timer that waited
a certain amount
of time before doing something, or a node that played animations.
And you can later on.
Once you've saved a scene, use that in place of a node in other scenes.
So for example, we could have one big scene which contains our player scene, our
level scene, and
five enemy scenes, and they can all interact.
So that's fundamentally how those building blocks fit together.
And they are all visible in the scene tree.
So in the top left we can view all of the scenes and nodes in our current scene.
And we're going to want to choose a node to be the root node or the base of our
starting scene.
So let's select a 3D scene as the root node, and we get this node 3D added as the
main node of our
current scene.
And we can add new nodes as children of this node.
So if we want to add something visible in the main viewport, we can have a look at.
We can add a mesh instance 3D.
We can add new nodes to the scene, either by clicking the plus button in the top left,
or as you can
see from the tooltip that's cropped up, we can click control and A to directly open the
Create New
Node dialog.
So let's click that plus.
And within this Create New Node window we can search through all of the nodes
available in Godot engine.
And there are a lot of them.
In order to effectively search through it.
There is a search bar at the top where we can type in part of the name we're looking
for, and it will
restrict this tree view to show us only nodes with the same name as what we've
searched for.
So we want to find a mesh instance 3D.
So let's type mesh instance 3D into the top and you'll see it's only showing us nodes
with mesh instance
3D in the name.
Click this one, not the multi mesh instance 3D, but the one that is just mesh instance
3D.
And we can click the create button in the bottom left, and that node will be added
into the scene tree
as a child of our root node.
So now we have access to a node.
We want to start fiddling with its properties so that we can choose how it looks.
And we access the properties of a node or seen through the inspector.
And that's the second to last thing we need to look at in the editor.
And that's this panel on the right.
Well, this doc on the right.
Which currently has the inspector selected and it says Mesh Instance 3D because our
mesh instance 3D
is selected in the scene tree.
This means that we can fiddle with that mesh instances properties, and it has a whole
bunch of properties
controlling its position and rotation and things like that.
But we want to control its mesh.
So you can see this mesh property here.
This controls the mesh that it will show us in the 3D viewport.
If you click on this drop down on the right of that property, we get a pop up that will
show us a variety
of default meshes we can add.
So for example, we could add a box which is like a cube or a cylinder, or a prism, or a
sphere,
or text or a torus.
We can choose whatever shape we want to add.
I'm going to choose a new box mesh and we will see.
In the middle of the viewport we have a new 3D cube.
With that box set up in the inspector, we can go ahead and use some of its other
properties to change
the position, size and rotation of this box.
If we scroll down in the Inspector down to the transform tab and expand it, we will get
access to positional
information, including its actual position, how it's rotated, and how its scale is, so we
can increase
or decrease its scale by changing this number.
There are two key ways we can interact with the number.
We can either click on the field itself, and it becomes a box that we can type a value
into like two
and hit enter.
And now our box will be twice as big.
Or you can actually click and hold on the number itself and drag left to make it
smaller, and right
to make it bigger.
And if you want to do that with a bit more fine grained control, you can hold shift and
the amount
that will increment will be smaller.
So once we've settled on a scale, we can then reposition the box, but it's actually
easier to reposition
the box using the gizmo in the 3D viewport.
That's these arrows and arcs drawing around the center point.
We can move the box along an axis by clicking on the arrow on an axis like this y axis,
and dragging
up or dragging down.
And now as we drag up or down, it will either increase the position's y value or
decrease the position's
y value.
If you look over at the transform property on the right while I'm doing it, you can see
the values
it is setting that position to.
If you want to lock the motion to set intervals, you can hold control and it will snap
the value to
a whole number increments.
So it's going down one meter every time I go up or down now because I'm holding
control.
So we can zoom out a bit by scrolling the mouse wheel out and just put the box
somewhere we're happy
with.
I'm just going to use these arrows on the gizmo to move the box back and to the left.
And finally, we can use these arcs to change the rotation of our box.
So if we click on a point on the arc here and then we drag up or down, it will rotate
the box relative
to that point.
And you can see how the rotation value is changing over in the inspector at the same
time.
So we've made a box, scaled it, repositioned it, and rotated it.
And that's a pretty comprehensive view of how you can move stuff around in 3D
space.
The last part of the editor we haven't had a look at is this bottom panel, which
contains a bunch of
menus that will open under specific circumstances, for example, when our game is
running.
The output tab will tell us information about our game as it's running, and we can use
the debugger.
And there's a shader editor, and there's just a bunch of menus that will become
relevant later on.
So with that all said and done, we are on to our first challenge.
Most lectures will have a small challenge to reinforce what you have just learned.
I'll describe a task and you can pause the video and have a go.
If you get stuck or confused, that's all okay, because when we resume, I'm going to
walk you through
how I tackled the challenge by trying to deal with a problem on your own.
In this way, you're going to do a huge amount to reinforce your learning and keep the
stuff that I've
just taught you in your head.
So I want you to add a new mesh instance 3D to the scene.
Change its mesh to something other than a box mesh to try and see how those look.
And then change its position.
Okay, I will see you back here in a moment.
All right, so let's dive back into judo.
We want to add a new mesh instance 3D to this scene, so we need to click this plus
icon.
And we will see the same.
Create new node dialog with Mesh instance 3D already selected and we can click the
create button.
Now, you might notice that the mesh instance we've added is a child of the mesh
instance we just added
before, because that was selected when we added the new node.
Because it's a child, it's in the same position as that previous box.
You can see I can move it over here and it's moving this point, which is our new shape
separately from
the box.
So we can, with that object selected, go over to the inspector and in the mesh
property we can click
the drop down to the right of it and select a new mesh for this mesh instance 3D.
I'm going to add a sphere and we can see we've got a sphere over here that is
separate from our other
mesh instance.
We can reposition it with the gizmos.
We can drag around.
Go to the right, go down and we can use the transform property and change its scale
as well in the
same way.
And now we have our two mesh instances with different meshes, different transforms
with different positions
and different scales.
Because we now have two meshes in our scene, we can learn a little bit more about
how parenting works.
So at the moment you can see because of this arrow, we have our root of our scene,
this node 3D,
and we have that box we added that was a mesh instance that was a child of it.
And we have this sphere that's a child of that box.
Whenever an object is parented to another by default they move with them.
So at the moment if I move the box around, the sphere will move with it just like that.
If you don't want them to be connected to each other and move with the parent, what
we can do is we
can re parent this sphere to the root of our scene, and we just do that by clicking and
dragging on
that mesh instance and dragging it onto the root node.
They're both now children of that same root.
And when we move the box, the sphere won't move with it.
And when we move the sphere, the other box won't move.
But you will see that the name of this sphere has changed.
It used to just be mesh instance 3D, but now it's changed to Mesh Instance 3D two.
That's because this node already had a child called Mesh Instance 3D, so it needed to
give it a unique
name as a child.
And that's it for this lecture.
In the next one, we are going to cover setting up our project a bit more and getting
used to running
scenes.

Running The Game

In this lecture, we are going to learn how to save and load our scenes, and we are
going to learn
how to start running our game.
So in this scene we've created with our two mesh instance 3DS, we can tidy things up
a bit by learning
how to rename the nodes in our scene tree.
So with the nodes in our scene tree, we can double click on them.
And when we do, we get a text prompt where we can type in new names.
So I'm going to rename the mesh instance 3D to cube mesh so that someone just
looking at the scene tree
can see that that mesh is meant to be a cube.
And I'm going to rename this one to be Sphere Mesh.
And then we can rename the root node of our scene to something meaningful.
And I'm just going to call this pair of meshes.
And now whenever someone's using this scene, they will see that the scene contains a
pair of meshes.
And with that renamed and organized, we can move on to actually saving the scene.
There are two ways we can do that.
We can either hit control and S to save, or we can click the scene dropdown in the
menu buttons in
the top bar, and we can click either Save Scene or Save scene as.
I'm going to click Save Scene and it will open the save scene as prompt.
If we click this little eye icon in the top right, it will make any invisible files visible.
So you can see the Godot folder that we expect in the root of our game project files.
It will autocomplete the name of our file to whatever we've named the root node of
our scene.
So we've got pair of meshes dot scene.
And if we click save.
This is saved.
And our file system now contains that packed scene.
That means we can add this scene to other scenes.
So let's give that a go.
Let's click the plus button in this tab bar at the very top of the viewport to create a
new scene.
This scene is also going to be a 3D scene.
And inside here we want to add that pair of meshes.
There are two ways we can do that.
We can right click on our root node and instantiate a child scene.
Or we can right click on the scene and the scene tree and click instantiate from there.
And both of those will do the same thing.
If we click on Instantiate Child Scene in the scene tree, it opens an Instantiate Child
scene prompt
that will show us a list of all of the packed scenes we have saved in our file system.
Because there's just the one here.
If we click open, it will open that scene.
Now, if we scroll the mouse wheel out to zoom, you will see we have the pair of
meshes available right
here.
So with this new scene created, I am going to save this scene and I'm going to call it
level.
I did that by hitting control and s to open the prompt, and then I can click save after
I've typed
the name in.
And now we have a new scene called level.
And this is a scene that we can run.
This is going to be a little bit underwhelming though as you will see in a moment.
We have playback controls in the top right.
We have a play button that runs the whole project, or we have a run current scene
button that plays
whatever scene we've got open.
The project has a main scene that it runs by default, and when we click this Run
project button, it
will ask us to select what that default scene should be.
So if I click play, it'll say no main scene has ever been defined.
Select one and I'm going to select current.
That will select this level scene.
In fact I won't select current.
I'll open the select prompt.
That will open the file system.
And let us select specifically which file we want.
So I'm going to click on this level scene so that that level scene, not the pair of
meshes becomes
set as our main scene.
And now whenever we click that play button or F5 it will run that level scene.
So I'm going to click open.
And that scene is the main scene.
And we can run the game and open this new running game window.
Now, this is exactly what I was saying.
It's going to be very unimpressive.
And that's because a scene needs a few key nodes in order to actually show us
anything worthwhile.
At the moment, everything's gray because we don't have a camera.
So I'm going to close that scene.
And in the scene tree on the left, we want to add a new camera 3D node.
If we right click on that root node and click Add Child node, it will open the Create
New node prompt.
And we can search for camera 3D.
With that selected, we can click create and a camera 3D gets added to our scene.
And if we scroll the mouse wheel in and click the mouse wheel in and drag around to
pan a bit, we can
see just about where it is in the middle of our scene.
That magenta shape is showing the direction the camera is facing.
So that square is a representation of the projection that will become our view.
If you want to see what the camera can see, you can click the preview button in the
top left.
And you can see it's looking straight forward.
And it can actually just about make out the sphere and the cube.
If we want to really make sure that it can see those, we can move it backwards using
the gizmo.
So I'm going to drag it a bit further back.
2.5m and click preview.
And now we can see things a bit more clearly.
We've got everything a bit more in focus.
Now that we have a camera in the scene, when we run things, we will see a bit more,
but it still
won't be right.
So now we can see that there is a cube and we can see that there is a sphere, but
everything's gray.
And the reason everything's gray is Godot needs a node called a world environment
that tells it how
it should shade everything you're looking at and how it should draw the background.
Now, this might be surprising because if we close that, we can see we've got a
background and we've
got shading visible in the viewport.
And that's because the viewport already has a world environment and a light set up
that's hidden by
default.
If we want to go and make our game look exactly the same as the viewport is here,
there is a shortcut
to do that.
If you look at the top of the viewport in this toolbar, you'll see these three vertical
dots.
If you click on those, you'll get a prompt to add a preview son and a preview
environment.
You can click the Add Son to Scene button, and it will add the son directional light
into our scene.
If we look in the center, you'll see there is now a directional light here, which has a big
arrow
showing the direction it is pointing.
And if we click those three dots again and we click Add Environment scene, we get a
world environment
node.
Those are the two key nodes it is using to get the appearance we can see in the
viewport right now because
those are present in our scene tree.
When we run the scene now, it will look just like it does in our viewport.
With that set up, I'm going to move us onto our challenge.
In that level scene.
I want you to instantiate the saved scene two more times.
And then rename and reposition those instantiated scenes.
Because the scene we're instantiating has a cube and a sphere in it.
Our overall scene at the end should end up with three cubes and three spheres.
After all of this repositioned and floating in space however you like.
This will show that you know how to use scenes that are saved and reused them, and
also just get you
a bit more familiar with moving things around with the gizmo and interacting with the
scene tree to
rename them and make sure all of these scenes are parented to the root node of the
level scene.
Okay, I'll leave you to it and see you back here in a moment.
All right.
So we want to instantiate this scene two more times.
I am going to close the running game project.
And I am going to right click on the pair of messages we've got in the C in the file
system and click
instantiate.
And that will instantiate a new copy that is exactly on top of the nodes we've already
got.
And you can already see I've made a little mistake there because I added it.
As a child of the world environment, I wanted this pair of meshes to be a child of the
root node.
So I'm going to drag that onto the root node so that node three d becomes a parent
of this new pair
of meshes.
And this pair of meshes has been called pair of meshes to I'm going to select that.
And then in the inspector I'm going to use its transform properties to reposition and
scale it.
So I'm going to scale this cube and sphere down using its scale property, and I'm
going to move them
further back.
And now if we look through, we'll see those two past each other.
I wanted to us to instantiate two new instances of that scene.
So I'm going to right click on pair of meshes again.
And I'm going to click instantiate again.
And now we have a third pair of meshes.
And you can see that because I didn't have anything in the scene tree selected, it
actually just added
that as a parent of the root node.
So it's actually at the right depth.
This one though I am going to rotate.
I am going to use this blue arc to spin it so that the cube is on the bottom and the
sphere is straight
above.
And then I'm going to scale that up actually.
There we go.
We now have three instances of our saved pair of meshes seen, and that shows you a
bit more of how
you can save and reuse these scenes for use in your games.
The last step I think I wanted to do was rename these.
So I'm going to rename the root node to level.
And actually, I think the names work.
Okay.
I'm going to call this one Vertical Meshes.
Because they're aligned vertically compared to these two sets of horizontal ones.
And now there's just a bit more meaning to anyone who's looking at those scenes.
Okay with that set up, it's worth knowing a little bit more about how default scenes
work, because
you may very well want to change the default scene.
If you come to some point in your project and you found a new scene that you think
would make a better
main scene, for example, if you had your first level, that was your main scene, and
then later on
you built a main menu, you might want to change the scene that opens when you run
to be the main menu,
because you can go from there to find all your other scenes.
So if you want to change the main scene, we find it in project settings.
Go to the top bar and look in the top left in the menu buttons and click the project
dropdown.
And there we will find Project Settings.
This opens a new window that has a bunch of settings related to how our game runs.
So you can see things like the name of the current project which is learning Godot,
the default icon,
a description.
There's absolutely tons of stuff down this tree on the left.
We want to look under the run tree branch, which is in the application tab, and you
can see there
is a main scene.
If we click this undo button, it'll get rid of that level seen from there, because you can
reset most
properties by clicking that undo arrow.
To select a new scene, we can click this directory button on the right and it will open
the file system.
And from there we can choose what the main scene should be.
I'm going to reset that to be level scene and then close the project settings.
Now, if at any point you want to run something other than the main scene, we have
access to this run
current scene button.
So at the moment if I click play, it will open the level as before.
But say I wanted to return to a pair of meshes and I wanted to run this one.
Well, I could click the run current scene button with this open and this one will run.
But as mentioned before, it won't have a world environment or a directional light or a
camera, so
we won't be able to see anything.
But you can see this is the scene that runs because it doesn't have any of that stuff.
That was in our level scene.
And that should cover a bunch of the essentials for getting started and using Godot.
That's it for the introduction.
The next topic we are going to dive into is making our first game project, which is
called Project
Boost.

You might also like