IN THIS LEVEL
It’s not all fun and games, but let’s have some fun!
In Level 2 you’ll learn how to:
Create Scene Objects
Create Mesh Libraries
Create Grid Maps
Build a Level Using Grid Maps
Start Thinking About Game Design
“We’re going to be getting you thinking about what kind of RPG you want as you build your first level. It’s never too early to start designing your game!”
Creating Mesh Libraries
The MeshLibrary object is used to store a bunch of items. It is a binary Resource file. It contains a list of Mesh resources - in other words our 3D models that make up our walls, floors and stairs. It can also contain their collision (although there are limits on that) and navigation data (which we will get into later).
To create mesh libraries, the first thing we need to do is create map scenes. Each scene will contain objects that are of a similar size, so that they can be placed appropriately. Remember last level when we had you separate all those dungeon pieces into separate folders? That’s going to pay off now, by making this step incredibly fast. We were lazy! we made the divisions of our assets on import, so that we didn’t have to think about organizing them later.
Scene (Menu) -> New Scene.
Click the 3D Scene button. (Scene tab, under Create Root Node:)
Rename the root node to “FloorMapSmall”.
Click the first model in Filesystem -> assets -> models -> dungeon -> floor_small.
Shift + Click the last file in the folder. (All the files in the folder should be selected except the texture.)
Click and drag all the selected files onto the FloorMapSmall node.
Press Ctrl + S.
Save the file in assets -> mesh -> scenes. (Make the new folders.)
Scene -> Export As… Mesh Library…
Type in the node name as snake case, ending in
.meshlib
. (FloorMapSmall becomes “floor_map_small.meshlib
”.)Save the file in assets -> mesh -> libraries. (Make the libraries folder.)
Repeat steps 1 to 11 for the models in the other folders, with the following root node and mesh library names:
floor_grate - FloorMapGrate -floor_map_grate.meshlib
floor_large - FloorMapLarge -floor_map_large.meshlib
floor_xl - FloorMapXL -floor_map_xl.meshlib
stairs - StairMap -stair_map.meshlib
walls - WallMap -wall_map.meshlib
Now we are ready to use all of these mesh libraries in grid maps!
“If you want, you can organize all the models by moving them so that they can be seen in each scene, but this is not necessary. In fact, you won’t even look at these files once we are done unless you add new assets.”
“You’ll notice the FloorMapSmall scene was saved as floor_map_small.tscn. Part of the Godot style guide is that all filenames are lowercase and words are separated by underscores. This style is called snake_case. This is a built-in feature that helps us be lazy. We don’t have to worry so much about filenames, Godot always has a well-formatted suggestion”
Read More: GDScript Style Guide
Creating Grid Maps
We now have our mesh libraries, we can load them up into a GridMap object. We could just add one to a scene and start using it, but then when we want to make a new scene, we have to configure it again. So, we are going to make GridMap objects. The reason we are making so many is because one GridMap can only handle objects of one particular size. So, we need five. Let’s make them!
Right-click on res:// in the FileSystem and create a folder named “environment”.
Create a folder named “grid_maps” in the environment folder.
Right-click on the grid_maps folder.
Select +Create New… -> Scene…
Select option 4, Node.
Click the Tree icon. (To the right of the word “Node”.)
Select GridMap. (Remember you can use search to find it!)
Click the Pick button.
Type “small_floor” as the Scene Name.
Click the OK button.
Drag and drop
floor_map_small.meshlib
into the Mesh Library field of the SmallFloor GridMap. (Inspector -> GridMap -> Mesh Library.)Turn off the Center Y value. (Inspector -> GridMap -> Cell -> Center Y.)
Ctrl + S.
Repeat steps 4 to 11 for the other Mesh Libraries, then modify them with the following Cell settings:
floor_map_grate.meshlib - grate.tscn
x = 1, z = 1, Center X = off, Center Y = off, Center z = off
floor_map_large.meshlib - large_floor.tscn
Center X = off, Center Y = off, Center z = off
floor_map_xl.meshlib - xl_floor.tscn
x = 8, z = 8, Center Y = off
stair_map.meshlib - stairs.tscn
x = 0.5, z = 0.5, Center X = off, Center Y = off, Center z = off
wall_map.meshlib - walls.tscn
x = 0.5, z = 0.5, Center X = off, Center Y = off, Center z = off
Now that we have our 6 GridMaps, we are ready to create our first room!
“As you start designing your game, an important technical question is what platforms are you targeting? You have 5 options with Godot: Windows, Mac, Linux, iPhone/iPad, and Android (Phone/Tablet). Is your game a casual game? Will it require complex controls? What camera options will be available? These are things you should be thinking about. It will change how you design your levels. Until we delve into these questions later on, we are going to stick with generic level building just so we have a world to stand on - literally.”
Building a Room
Let’s make a scene and populate it.
Create a new empty scene (Scene -> New Scene).
Create a root node of 3D Scene by choosing that option in the Scene tab.
Double-click the new root node’s name, “Node3D”.
Rename the root node to “Room01”.
Press (Ctrl + S) to save the scene, and put it in the environment -> rooms directory. (You’ll have to make the “rooms” directory.)
Drag and drop all the GridMap scenes onto the Room01 node.
Select one of the SmallFloor GridMap you just added. You’ll see all the meshes in a list that pops up on the right-hand side of the viewport. In the toolbar you will see a new Floor indicator with up and down arrows, Next to that GridMap menu. Clicking on that will give you a bunch of commands along with their shortcuts. The most useful ones are to the right. Play around with the GridMap features and get comfortable with them.
If you like, play around with the Cell settings we set in the last section. You’ll see that small floor meshes do not overlap, but large ones can when you place them. This is a waste of resources. You can change the large mesh cell settings to x = 4, z = 4 to stop that overlap, but then you cannot place them in the middle of an 4x4 section. Instead, we recommend painting with small floor meshes and placing the large tiles.
Once you play with the meshes, you may decide you like the freedom of the x = 0.5, z = 0.5 settings of walls and stairs. You may want all your tiles to do that. You can, but beware of painting in that case. You could even create a new mesh libraries and GridMaps that are location specific. For example all dirt floors in one, all tile floors in another. Do what works for you.
Once you have experimented for a while, create a 16m x 16m room. For reference, each small floor mesh is 2m x 2m square. Each large tile is 4m x 4m square. If you zoom in, you will see the smallest set of grid lines a 1 meter apart.
When you are done, you will have something that looks like this (note some of these walls are only available in the Extra or Source version of Dungeon Remastered):
Make sure you save your new room scene (Ctrl + S).
GridMap Controls
S: Rotate mesh on the Y-axis
Left-click: Paint mesh. (You can click and drag.)
Right-click: Erase mesh. (You can click and drag.)
Shit + middle-click + drag. (Highlight multiple placed meshes.)
Ctrl + X: Cut Selection (All highlighted meshes attach to cursor and can be placed with a left-click.)
Ctrl + C: Duplicate Selection (All highlighted meshes are duplicated and those attach to cursor and can be placed with a left-click.)
E: Go up a floor.
Q: Go down a floor.
Moving around in 3D View
Mousewheel up/down: Zoom in/out
Middle button + drag: Orbit the camera around the current target.
Shift + middle button + drag: Pan camera up/down/left/right.
Right-click + drag: Rotate the camera in place.
F: Focus on the currently selected object.
Shift + F: Switch to Freelook mode. You can use the WASD keys to fly around the scene while aiming with the mouse. (Press Shift + F again to exit Freelook mode.)
“Level design is the first place to show the style and setting of your game. Are you using a lot of broken-down walls, or is this dungeon new? Is this a dungeon, an old mine, a bar, a shop, or a brand-new castle in the center of town? Do you plan to populate it with just things to look at, or lots of things to interact with? Will there be puzzles, monster that attack, NPCs that talk to you? What do you envision?”
Level Up!
Congratulations! You’ve leveled up! You’re ready to move on! We’ve made all this stuff, and we want to make sure we don’t lose our work. Our level 3 quest will take us into the world of GitHub. There we will learn how to make a repository, and check in our code. This is a very important step in being a real developer.
After that we will be moving on to Level 4 where we will make a player character. We will learn how to collect input from the player to move our character, how to animate our character, and how to attach a camera. By the end of the level you will be running around in game for the first time!
“Welcome to Level 3! Keep up that momentum!”