Making Game Levels for 2D Godot RPGs with Tiled | Christopher Navarre | Skillshare

Playback Speed

  • 0.5x
  • 1x (Normal)
  • 1.25x
  • 1.5x
  • 2x

Making Game Levels for 2D Godot RPGs with Tiled

teacher avatar Christopher Navarre, Software Instructor

Watch this class and thousands more

Get unlimited access to every class
Taught by industry leaders & working professionals
Topics include illustration, design, photography, and more

Watch this class and thousands more

Get unlimited access to every class
Taught by industry leaders & working professionals
Topics include illustration, design, photography, and more

Lessons in This Class

13 Lessons (2h 29m)
    • 1. 0 Introduction

    • 2. 2 Getting Up to Speed ~ Starting Point and Assets

    • 3. 3 Creating Tilemaps and Tilesets in Godot

    • 4. 4 Installing Tiled and Tiled to Godot Plugin

    • 5. 5 Export Tiled to Godot Workflow

    • 6. 6 Tiled Basic Tools and Tilemap Layers

    • 7. 7 Tile Collisions and Display Sorting with Tiled Maps

    • 8. 8 Tile Faster with Terrain Sets

    • 9. 9 Building Our Village ~ Collisions, Bridges, Level Scenes, and Camera Limits

    • 10. 10 Building a House Interior

    • 11. 11 Placing Level Switch Triggers and Spawn Points

    • 12. 12 Spawning Player with Game Manager

    • 13. 13 Switching Between Levels

  • --
  • Beginner level
  • Intermediate level
  • Advanced level
  • All levels

Community Generated

The level is determined by a majority opinion of students who have reviewed this class. The teacher's recommendation is shown until at least 5 student responses are collected.





About This Class

In the course, we're going to be learning how to build out levels complete with layers, collisions, and trigger zones inside of Godot. For building levels we focus on using the Tiled app and exporting from Tiled back into Godot as it streamlines the process of level building for the current 3.4 version of Godot. We will be covering how to spawn character objects into your levels during gameplay and how to transition between levels as some of the later concepts.

  • Learn many core concepts of using the gdscript language to build Godot games
  • Build 2D RPG levels with collisions, layer sorting, and level transitions
  • Use Tiled and Tiled to Godot Exporter to improve your level building process
  • Create a working 2D character controller with a follow camera
  • Spawn characters into your levels on the fly
  • More content to come in the near future

Here's the starting point for the course. It includes scripts from part 1 and the necessary art assets for this course.

Starting Point for this Course

Course Series on Building a Top Down 2D Godot RPG

Project Start Files

Tools Used

Tiled Map Editor

Tiled to Godot Export Plugin

Art Credits

Generic RPG Pack by Bakudas

Craftland Demo by Szadiart

Pixel Art Adventurer Sprites by Elthen

Super Retro World - Interior Pack by Gif

Meet Your Teacher

Teacher Profile Image

Christopher Navarre

Software Instructor


My philosophy in information technology and learning in general is that video learning is the best way to learn for yourself. I can provide the videos but it's up to you as my student to absorb and practice the information to become a more educated and skilled person.

If you want to get a taste of my approach to education and tutorial series, you can find me on my YouTube tutorial channel Chris' Tutorials.

See full profile

Class Ratings

Expectations Met?
  • 0%
  • Yes
  • 0%
  • Somewhat
  • 0%
  • Not really
  • 0%
Reviews Archive

In October 2018, we updated our review system to improve the way we collect feedback. Below are the reviews written before that update.

Why Join Skillshare?

Take award-winning Skillshare Original Classes

Each class has short lessons, hands-on projects

Your membership supports Skillshare teachers

Learn From Anywhere

Take classes on the go with the Skillshare app. Stream or download to watch on the plane, the subway, or wherever you learn best.


1. 0 Introduction: Hello everybody, cursor. And in this video I wanted to talk a little bit about what to expect from this course on building 2D RPG game levels inside of the Godot game engine. So one of the first things we're going to be talking about our tile maps and tiles sets inside of Godel. So tile maps being where you place your individual tiles. As you can see by having multiple layers of tile maps, you can actually have different tiles occupying the same space, having like a tree behind a house, for instance. And then your tile sets or where you actually pull the tiles from. So these are based on images that you import into Godot, but you can, of course see that the tile map tools are a little bit wonky at the moment in the 3.33.4 versions of Godel. In this course, we're going to move on to using the tiled map editor, which I think currently is a smoother way of creating your maps. And then there is the tiled to Godot exporter, which we also cover of course, on how you can export these maps straight into Godot. So whenever you make a change to your maps or your different tile map layers or your tile sets. You can export all of that to Godel. As you can see, the tile map editor and the export or do support having collision maps enabled here. So once you edit your map here and you export it over take Adele, you should be pretty much good to go for that. So the portion that we really need good DOT 4 is going to be the actual game logic. So if I jump over to one of these level maps that we're going to be creating. You can see that we attach some scripts to the village houses and we also have these transition zones and spawn point zones. So part of the course is going to be on how you can spawn a player, say a start location. So as you can see here before our game starts, there is no player loaded into this level. But with some of the coding we're going to be doing, we can have players spawned dynamically loading here at a spawn point. Or when we enter the house by using these area to d zones, we can load a new level and then spawned the player inside of that as well. So we're going to be handling that sort of level transition in this course, I can go ahead and quickly demo what that would look like. So we get to this area to diesem and we pop inside the house. So that's loading a completely different scene and creating the play once again inside of that scene. So a couple more of the topics we're going to be touching on that will help when you're building out your game levels using the tile map editor include that when you are tiling is essentially the same grass or sand tile that you can set up priorities for variations of those tiles. As you can see, these are all glass tiles, but some of them have a little bit of extra detail added like some rocks or very visible grass sticking out of the ground. And then with this anthills over here, once again, it's kinda the same thing. Some of them have some light vegetation and somehow rocks. And so we can get that to occur by setting probabilities for each variation of a tile and then tiled, we'll kinda randomly select between those. Another thing that's very helpful is terrain sets. So when you have different types of terrain that have tiles that border each other, like the sand to the water transition or the sand to the grass that you can select the type of tiled and tiled. We'll be able to automatically select the exact tile after you set up some rules so that things like your rivers look right or you aggress borders the sand with the correct title. So I could just kinda quickly demo that. Let's use this dirt terrain and the base ground. And so you can see how without really manually selecting which tile I want to appear here, we can just kinda automatically fill that in. It is really helpful and a big time-saver. So that in a nutshell, is a lot of what you can expect from this course on making 2D maps for the Godot at game engine with the tile map editor and Godel. And this is actually part 2 in my larger core series. So if you want to see part one on building the character controller, then you can find the link in the course description as well and go watch that as well. But that's not required. You'll find the character scripts already provided for you as well in the course description for the starting point for this project. If you're looking to build a 2D RPG or just a 2D game in general, then I hope this course will be helpful for you and I will see you in the first video for the course. 2. 2 Getting Up to Speed ~ Starting Point and Assets: So before we get started with this series, I kinda wanted to bring up this starting point for these tutorials. What you see on screen is the end point for the first series, which is optional. You don't have to go watch that part on creating a movement controller and adding props to the scene. If you don't want to. But just be aware that this is going to be our starting point and you can download these files from Google Drive. I'm going to share a link to this in with the link to this Google Drive folder, you're going to want the 2D top-down RPG game levels and Godot dash start. So I will have this readily available. You can go ahead and download the files. Now if you didn't watch the previous part, then you know that we were working out of this generic RPG pack as the main art assets. But since this series is going to be dealing more with level building and tile maps. And then in a future part, I'm going to want to be adding some combat as part of these videos. So I did grab a few more our asset packs which are going to be included. And that can go ahead and show what each of those are going to be. So first up over here we have the demo version of craft land by Sadie art. You can see it's very, very nice pixel art. So looking forward to using some of that, on this next tab over here, we have pixel art adventure sprites, and this one is from the game def marketplace. You'll notice that this character has many different animations, including so it swings. And a bot animation, which will be very helpful when we decide to add some attacks to a player character. And then as the third one, we have this super retro world also available on each dot IO. The craft gland is each dot io as well. And this is an interior pack you can see over here. So we may have need of those assets as we add the ability to change between scenes, we'd want different levels to be able to load. For instance, being able to enter a house map from the main village map. So once again, these are included in the zip file as the start for this course. And when you load it up and get dau by opening the project file. And then you should see basically what you've got in here art, these four packs. We have the Character Script and seen from the last series, and a test map. That's what you see on the screen and some props based on the static object. We have the pond in and barreled read as objects we were able to add to the scene and collide with. So that is the starting point for this series of videos. Once again, if you want to learn how to add basically everything we see on screen, the ability to have player script move around the screen and have a follow camera follow it, then you can check out Part 1. Otherwise, we're going to move forward now with using tile maps and building out levels and switching between levels. 3. 3 Creating Tilemaps and Tilesets in Godot: So in this video, I wanted to talk about the tile map tools built into kiddo 3.3.4. And this will still apply leading up to version four. Eventually they do plan to revamp the tile map system, which might make it look different in the future. But for right now, we'll talk about what you can do in the current version. So currently I have test map open. If you do not see this currently, then you can open up the test map, which is in the maps folder, and then double-click on test map.get TSC. And so to add a tile map to our test map, I'm going to right-click on the root node. That's this node 2D contest map up here at the top and add a child node. So then if you type in tile up here, you will be able to find tile map for 2D based tile maps. That's what we want. So we can go ahead and create that here. And then to make sure that it renders below everything else here, like these individual objects to that player. And I'm going to pull this up to be the first child on the list. So whatever is on bottom shows on top of whatever's on top here. That's why a texture wrecked is also made up here at the top. Otherwise, it would look kinda like this and that's not what we want. So our tile map is going to need a tile set in order to actually start putting down individuals 16 pixel by 16 pixel tiles onto the tile map to create our background. So I'm going to click on tile map. And then over on the right we have a option here called tile set. So in this property we need to click here and choose new tile set. So there's new tile set is going to need to images in order to create the tiles from that we use on our tile map. So we can click here, left-click, and then we can drag some are into this folder. Now another idea before we jump into that is that for this tile set on the tile map, we can actually right-click on this and save it as a asset inside of our project. So we might actually want to reuse the same tile set across multiple different tile maps. And I think that's actually a pretty good idea for the reusability of it and to make sure that we always have it saved in our projects so we don't need to recreate it. So you can right-click tile set and then choose save. And we can save this into, go into the maps folder. And then I'm going to create a new folder in here. And I'll call this tile sets. The reason I'm creating it in maps is that the tile maps are always going to be on a larger map. So this is kind of like a subcategory of our tile map assets. So let's create that folder here. And for this tile set name, I'm going to call it craft land dot t RES and hit Save. So now inside of the tile sets photo, we actually have this tile set. You can double-click it and you can edit it here in the same way that if you click on tile map in our currently open scene and you click on the tile set now you can see it's a TRE, Yes, It's not just a name of an object, but it's actually a saved file in our project. We can click on that, open it up. Exactly the same thing. Okay, so now that we have this in our project, we want to bring in some assets, like you would expect from the name here. I'm gonna go into art and open up this craft land demo folder. And I'm going to bring in this atlas. So any sprites are going to generally be saved as a PNG file so that they can support transparency where there's no pixels drunk. And we want to drag this into our list here. So with that, we have this image which we can create tiles from. And these tiles are going to end up used on our tile map. So for this image, I want to zoom in on it over here so that we can actually see what we're doing here. Now you have a few different options here for creating your tiles. So you have new single tiles when you just want to take one square and make it its own thing. So whenever you click on the tile and the list of options, you click that one specific tile and then you click on your map. You have atlases, which basically group tiles together in one category. So you would click on the Atlas tiled group and then select the subtitle from down below. Atlases do support things like being able to randomly select one of the tiles in that atlas and then draw that onto a map. And then auto tiles are also a form of grouping tiles together. And you set up rules with bitmask. I'm not going to be doing that because honestly, the current bitmask tools are really hard to use. And I think it's going to cost us more time then it's going to save. So if you want to create a single tile, you could do that pretty easily just by clicking on new single tile and then drawing a region here. Now as setting you definitely going to want to enable is this snap to grid, because of these tiles are 16 by 16 pixels. So if we snap our selection to 16 by 16, then we'll get the right selection for all of the artwork. And our game will look correct. So we definitely want to enable that snapping. But you can see here that the default for this grid is more like 32 by 32, but the actual tiles we want our 16 by 16. So if we click on the tile map up here and we go down to the cell. You can change the cell size to 16 by 16. So that's important so that when we actually draw onto the tile map grid, you can see that each of these squares that we're going to be drawing on our 16 by 16. Now let's click on the craft gland. So here you can see that when we haven't actually created any tiles from the art, it doesn't automatically save. I'll drag the art in here again, craft land. So now we want to create a tile. I'm going to hit New single tile. And then let's just select up here in the top left. So n-region mode, selecting an area for a tile. So if we click new single tile here and we select a square for a region, we can go to snap options and change the step size down to 16 by 16. When we do that, now, the purple lines are going to be cut and fourths. And this is going to be the correct size for each of the tiles. If we zoom in real close, you can see that each of these tiles makes sense now as they're all their own separate artwork. And we're going to want to be placing these individual tiles strategically in order to build out a varied game map. So make sure that your step is set to 16 by 16 and that on the tile map It's also set to 16 by 16. Now that we've corrected the snap options up here, we can actually create our tiles properly. So if we want to, I can click over here and then this will be one tile. If I hit this information button, we can see the name of this tile that we are creating. And if we click on the tile map now, we'll be able to place this tile abound our game world. So if I left-click hold and drag a few of these tiles, we can't see them because the texture vectors actually showing in front. So if we hide the texture vector, now we can see our tiles. So that's just keeping in mind the ordering of your tile map and other objects in your scene? Correct. And that's also going to be important when you use more than one tile map, which won't need to do in these tutorials. So I'm gonna hit Command Z a few times, get rid of those, and let's still hide the texture effect. So we're basically left to an empty time up. And let's go back to our tile set here because we have a tile, it did save still. So we do want to see craft land dot PNG there every time we do things. Next, let's create a Atlas and we're not going to be doing any random tile generation with the atlas, at least right now. But what we are going to want to do is to group all of these tiles as one set so that it is a little bit easier to work with if you zoom out and you see this entire atlas of tiles, the whole document, There's a lot here. So the more we can group tiles, the easier it's going to be to work with. So let's zoom in a bit here and I'm going to create a new atlas. And now we need to define a region so you can left-click, press, hold and drag in order to define all the tiles that should be in this atlas. So I'm just going to select this bit. Now we have craft land dot PNG one. If we want, we can expand selected tile on the right and rename this to something that makes more sense. I think that could be helpful for us. So I'll call this something like elevated grass. Hit Enter. And now if we click on timeout, we can see our elevated grass over here on the right. If we click on that, because it's atlas, we'll see all of our tiles down here for selection. And we can select each of these tiles in order to draw them where we need them on the map. So I can just go ahead here and draw nine of this tile. Note that these four metal tile, so the same, so it doesn't really matter which one you use. And then we can use the side tiles to make this elevated ground if you wanted, you could just fill this entire map with justice grass and that would be really basic and boring. But let's make this elevated grass. So I'll select each of these tiles individually. As you can see, this tile is a variation of the left edge tile. See, we could use this one or this one, and you can just left-click, press and hold and drag this tile as many as you need. Right-click removes it. So it's up to you basically how you want your left edge to look like. And then when we get down to the bottom, we're going to want to use bottom corner tiles and then the one below that in order to add more elevation to this elevated grass. And we just keep going around and selecting the tiles from the atlas and creating our elevated ground. So let's just do that a bit. Placing the tiles wherever you want them. And if you look at the tile set over here, that there are also these other pieces you can work with and these right here and these going to help you to create different kinds of elevated grass areas. So not everything needs to look like a square. You could create your own varied shape because they're more tiles here to work with so that you can get more interesting shapes while we're here actually, let's create a couple more atlases. So I'll do new atlas. I'll grab this box over here and I'm going to rename this, let's just call it elevated grass to do a new atlas for these tiles down here, elevated grass three. And just to add this stuff, end, just add this stuff. I think this might be some kind of stairs. So I'll add a new atlas for these four tiles. And I'll call this Round stairs, renaming them is just going to help it be more clear what you're working with when you see here. So now if we zoom in with these other atlases down here, when you select the atlas, you'll notice it'll show a number of columns depending on how far you have this window stretched out. So this was created with a two by three. So this is actually going to be the amount of stretching for this window that makes the most sense. So it's a little bit tricky to work with right now. But with these extra pieces, we can probably create a little bit more of an interesting setup here. So I'm going to replace some of those tiles down there. And let's see if we can kinda do something like this. It's going to be a little bit of trial and error. And then we have these top right pieces. So that allows us to create kind of a slanted slope for our top ground. It looks really cool. Let's go back to elevate address one. And this had a stretching of four when we created it. So we want to pull it out to about there to see the tiles most clearly. And let's see if we can connect this bit here. So that's not what we need. Maybe we just need this. Yep. Okay. And then this one down here. So that looks roughly correct. Obviously, when an artist is building out these tile sets, it does require some trial and error to get all of the pieces to line up correctly. But since we already just working with pre-made stuff, we just need to figure out what the artist's intention was. And then elevated grass here. Is there anything we can work with as well? Maybe let's create a little bit of rocks and here surrounded by elevated crevasse. So this is going to be very trial and error and just trying to make all the pieces line up correctly. Let's go back to elevate address one. Okay, so we can put that one there. And I'll put some pieces around this top edge here. And then on the top edge we want to show the wall again. So we're trying to build that up. And then this is going to take a little bit of trial and error, of course. And then let's do these corners over here with elevated grass three, okay. And the side piece. So kind of getting the wall there. This does look a little bit weird, so that might not be the right piece for that. Maybe what we need is actually more the one that shows the rocks. So let's try that one. Okay. Yeah, that looks that looks a lot better. And let's come down the side these pieces. And I think these corner pieces could be used from these ones over here, but we will need to rotate them. So when you wanted to select one of these tiles and rotate it around so you can use it in the exact position. You can use a and S on your keyboard in order to rotate it. So we want this piece and that position, and we can go over to this right side and use that one right there. So now we need a another piece for this one here. So that one was from elevated grass. Let's go grab that again. Just another one of these ones over here and rotate it to face the correct way. So now we've created basically a giant rock and closure of what will be some kind of lower ground layer that we can later use. So let's just fill in a few more tiles over here and we can get a rough idea of what this map can look like. So the last thing I want to cover for this video is how to show to create different tile map layers. Here's what would happen if we start just adding normal grass down here. If we draw these nine squares, it'll look fine. But you'll notice that there's some invisible pixels for all of these other surrounding wall pieces. If we draw over them, that happens. So we actually need a second layer to be under here. For the base ground, I'm going to hit Control Z to undo that. And I can take this tile map and rename it to be top tile map. And then let's create another tile map to fill those lower ground areas. So the lower tile map will always hide below the top pixels. Which means that if we use these grass tiles, but we put it here, it's going to show invisible wherever there's a rock pixel. And the grass will only show on the ground where the rock pixels or not. So this will help it look correct. Let's take the test Map, right-click it at a child node tile map. And we're going to put this, Let's see above the top Tile map because whatever's lower shows on top. So now we take this time map and rename it to be bottom tile map. For the tile set, we're going to use the same one, craft land dot TR. Yes, So you can just drag this from the file system onto our tile set. And now we have the same tools to work with. We don't need to recreate them. So let's click on elevated grass. Let's just select this grass tile. I mean, we could use a different one from the set over here. Maybe you want to create more atlases for these ground tiles. Actually, we could just do that. Why not new atlas? And I'm just going to drag these nine pieces. And I will call this sand bordering grasp. Since obviously you can see that the middle tile is the sand pixel, but on the edges we have that conversion between the sand and the grass areas. So now let's click on the bottom time map. We have this new type of tile we can use control the size of the window, and we'll just use this sand tile and fill that in wherever we need down here. Clearly we can see that the size on our new tile map is not correct. So we need to click on cell and change this to 16 by 16. So when we do that, now we can select our tile again and it will feel the correct sizes. So you just need to fill in everything under this rock wall here in order to fill in the gap pixels. So let's just left-click hold and drag a few of these tiles to fill that in there. If you wanted, you could have some of these border tiles. So I could just take this tile over here, rotate it so that it's facing the right direction and draw a line down here. And then for these styles over here, since that's clearly supposed to be grass, we can click on elevated grass and grab one of these grass tiles and fill that end there. So now we have sand converting into grass down here below. And we have this second layer down here below to fill in the gap pixels where our top wall layer should show on top of. So layering your tile maps a really handy. And clearly there's a few more minor flaws here. Like maybe I didn't select the right tile to convert between here and there. We could actually work on that for a minute. So if we switch back to the top Tile map, Let's see if there's another tile which goes in here to handle that conversion more, Let's see, this one does work from over here because the grassland connects. I think maybe that makes it look a little bit better. So they might not be exactly the right tile there, but if you vary your tiles up, that will help kinda break the flow a little bit. At the very least, that's a start. I could work on it a little longer. But that's just to basically show the idea of using tiles, connecting them together. And as you can see, if you have enough tile variations, you can connect your pieces in different ways, like having slanted slopes, which may have not been immediately represented by things like the square from the tile set image. So that basically demos the point of using piles to begin with, which is that you can use different pieces, combine them in interesting ways, and then create your own custom maps from a limited set of tiles. And we could keep going with this, building out our game levels straight from within ghetto. That is one option, but another option I want to show, which currently I do prefer is to use the tiled map editor and then import those maps back into Godot. I think that that helps streamline the process and speed things up a little bit more. So that is going to be what the next video is about. 4. 4 Installing Tiled and Tiled to Godot Plugin: So in this video, we're going to be talking about an alternative way that you can build your game maps for Godot using a tool called the tiled map editor. And currently, I'm finding that is bit easier to use this than the built and good DO tools. When Godot 4 comes out, that might change. But for right now the tile map editor is pretty good if you want to build 2D game maps. So you can find this program at map slash download dot HTML. You can also see here that the download link is available on each dot IO. So when you hear, you've got to click the Download Now button. And if you want to try the tool for free, you can just sit. No, thanks. Take me to the downloads and then select the version associated with your operating system and install it on your computer, just like you would any other program. So here at the bottom you can see I have tiled, I'm going to open that up. So alongside the tiled map editor to make our life easier, we're going to want a plugin called the tile to Godel exploits. So this plugin is going to make it so we can take the tiled format and convert it straight into the Godot seen or Godot V source files and basically open out, right and Godot and just start using it. So this plugin which you can get at slash Mike, capital M, lowercase n, capital D slash tiled dash, two dash, dash export is pretty easy to install. So if you click the Download button and you extract the plugin, you're going to get this tile to Godot export master. This is what you got to copy and paste over to these directories that you can see here. So a really easy way to get here is just going to be to select the path, copy it. And then in Mac I go to the top-left menu. Choose go to folder. In Windows, I think that's all you can just copy and paste the path n. And we gotta paste it in the same path from here. Of course, since I was sharing that reasonably, you can see it's already included here. So Let's go ahead and paste that in and we get straight to this folder. So then you just copy this over to this. Of course we're not going to do that because it's already there. And that's pretty much it. So now when we actually start tiled, we'll be given the prompt to create a new map and a new tile set. So like in Godot of the tile set is based on an image and it provides all the tiles that you build a map from. And then the map is the actual level that you're trying to build, which may use multiple tile sets. So let's finish up this part by hitting new map. And we're going to create a orthogonal orientation map. So that's going to be your straight down read like a chessboard. Isometric would be angled and then hexagonal would be instead of squares, we'd have six sided shapes for our grid. So tiled can do all of those. And we want to just create, Let's start with a fixed width maps. So I'll make a 80 up here by 60. I think that should be plenty. You could also do infinite if you just want it to stretch as much as possible. But I believe when you create your map, you can always expand it later if you need to. And the tile width and tiled size, we're going to have those set to 16 pixels. So let's save this map inside of our Godot project. So the 2D top-down folder. And then I'm going to put this in maps. Since we're making a map and we're going to export to a dot t SCN map scene file for right here. We'll call it tiled map one I guess. And just save it in there. So this is going to save as a t and x file, that is the tiled format. And then we're going to export using the plugin to asean file. So let's go ahead and hit Save. And now we can verify that our plugin is properly installed by going to File Export As. And we want to verify that on this list at the bottom here has the option to do could DO tile map format. So this is a format that is installed by that plug-in. If you see that, then theoretically plugin is installed. So we're not going to export here. We'll work on that more in the next video. This is just getting everything set up. So if you have tiled and you have the ghetto plug-in showing in piled, then you're good to go for right now. 5. 5 Export Tiled to Godot Workflow: In this video, I'm gonna be showing you guys how to set up a game map using the tile map editor. So in the last video, we already went ahead and installed the export a plugin. And we also created our first map, at least opening it up. And you can see in the left-hand side or orientation is orthogonal. So we have the chest like grid where vertical and horizontal lines go straight. And we have the tile width and height set to 16. It's important for that to match the actual size of the tiles we are going to be using from the image file. And then the width and height is a by 60. But you could have put anything you want. You can see AT base 60 is quite a few tiles. But do remember that as your camera follows, you play around the map that they generally, they are going to be going over quite a few different areas. So it's not just all on one screen of course. So in order for us to actually add some tiles to this tile map, we need to add a tile set, just like aimed Godel. And we can do that in the bottom right-hand corner where we have this button new tile set. There's also the smaller icon to add a new tile set if one's already been created and you just want to add another one to the list. So let's add new tile set here. And our tile is going to create tiles we can use based on an image. So we need to browse to that image. I'm going to hit Browse here, and then I will go to our project. And we're going to look in the art folder, the craft land demo and the craft land dot PNG. So that has all the tiles we need to use. Basically our entire atlas of tiles. Open that up. You can give it a custom name if you want. And then we just want to make sure that the tire width and height is correct here. If you want, we could rename the tile set to be Craft gland tiled, just so that it's very clear where this came from, especially when we export it back to the ghetto formats. So I'll just do that and hit Save As here. So safe as we need to give it a directory. And I'm going to put it in the towel sets folder that we created. So note that this is now two levels deep from the root of our project. That's going to be important because we need to specify in the custom properties over here where the project root is relative to our tile set file and the tile map. So we're saving it in tile sets. I'm going to hit Save. But now we need to add that custom property. So I'm going to click down here to add a property. And we're gonna give it the name Project Root. It needs to be written exactly like this as a string. So click Okay. And then you can either give it an absolute path. That would be where you start with the DR number and you drill down to the exact location of the file or you can use a relative path. So if you're doing a relative path, you start with the period which represents the current directory. This is just like if you were changing directories in terminal. And then we add a forward slash, and I'm gonna do two dots here to move up one directory. But remember that tile set folder or directory is two levels below the project roots, so we need to do that one more time. So forward slash dot, dot. And then that's going to give us the correct relative path to the project root. And that's important when we're exporting so that Godot kinda reads the location of our exported files correctly. We don't run into any errors. So I'm going to Control S and save this one more time. And let's go over to the tile map. So that's the HTML file over here. And you can see that the tile set is here, it's ready to use. And one really cool thing about editing your tile set maps in tiled is that you can press and hold on one tile and then drag a box around all of the tiles you want to use at once. So if I select this entire house, I can just find a location here, pop it in there. And I've just probably saved a lot of time by having to manually click on one tile and then press over here and click another tile and press over here. So that's pretty nice. Okay, so just like with the tile set, we also need the project root property added for our tiled maps. So I'm going to click on the plus button, Add Property and the bottom left. Okay, maybe it needs us to save the file first. So I'm gonna go to File Save As. And let's put this in maps. So the maps are still coming here and the power sets are going one level deeper. So tiled map one, sure we can save it as that as a dot txt file. Save, okay, so you can get the property thing to come back if you just reopen the file. So I'll just do that real quick. So close that Recent files, okay, and now that we have it reopened, let's add the property in here. So once again, Project Root K, we start with a period of representing the current directory, forward slash to jump directories and then two periods means moves up one directory. So the maps folder is one level below the project root. So navigating up one level is going to give us the actual project tree. So let's save that. And now we need to export both of these into the Godot format. And then we can open it up and you could do it. Okay, so let's add the house back in there and save the file. And I'm going to go to File Export As. And we're going to save it in this maps folder. So as a JSON file, so click on this dropdown and make sure that you are exporting to Godot tile map format. If you don't see that, then you may not have actually installed the export a plugin correctly. So you can go back to the last video and see how to do that if you need to. Let's go ahead and hit Save. Okay, and we need to do the same thing with craft land, tiled dot-dot-dot TSC x. And we need to do the same thing now with the tile set file, which I'm calling craft land child.type JSX. So let's go to File Export As. And this goes in the tile sets folder as I'm organizing it. So I'm just going to pop it in here and make sure that it exports as good. Oh, tile set format. That is S. Let's save it. And now we can switch over to get down. Okay, so back in our project, I'm going to open up the maps folder and we can see our tiled map.get asean is located here. And then under tile sets we have the craft land tiled ES file. So we should be able to open up the TRE S file and we can see our tiles already created. Here is one giant Atlas. Though. We're not going to be really using that in here. That's just to support our tiled maps. So let's open up tile map one dot-dot-dot asean. And we can see we have that house. We added n located right here. And that's pretty much going to be the basics of exporting from tiled two good dough and making sure that everything works well. So at this point, if we want to start adding tiles around the map or just add some random stuff here. Yeah, kinda like that. Why not? And I'll hit contrast to File Save and then we'll export it again. So making sure it's in the same directory as before. Let's replace it. Go back into goodwill, we reload it in there. Now our map has been updated. So basically the simple workflow is just going to be to make your changes and tiled, re-export it back into the ghetto formats, open it up and reload it and Godel. And then you can use it in the game editor. Basically just as if you had actually created it using the ghetto tile set tools directly. So if you've gotten to this point, if you've made sure that your workflow is working properly. In the next video, we'll go ahead and actually make a map with several levels entitled bring that into Godot. And we can use that as one of the base levels for the rest of our tutorials. 6. 6 Tiled Basic Tools and Tilemap Layers: In this video, we're going to be mostly focused on the basic tools and using layers in order to help build our map. So let's jump over to tiled map one over here, which we had messed around with a little bit before. I'm going to start by deleting this layer and the top right. So this is our layers box and you can see you can have a big list of different layers. And each layer is basically organized at a certain ranking visually above or below other layers. And whichever layer is on top is going to show below the other layers. So in a sense, it's sort of like having a note in Godot, but instead we've manually organized it using layers and manually ranking them, rather than their ranking being based on the Y position of each square on the screen. Why being vertical up and down, of course. So we're going to delete this tile layer one, and I'm going to add a new layer in here. So we'll make it a tile layer, and I'm going to call it base ground. So this layer for the map is just going to basically be the ground tiles that you would see that sit underneath everything else like a house or other objects you'll add to this screen. So in the bottom right, you should probably see the tile set high hills right now, right now I have it on the terrain sets tab, so I'm going to switch that over to tile sets for now. We'll talk about terrain sets in a future video. So our tile sets contain all of the tiles that we have for drawing on our map. Of course, we've already covered that. So if we wanted to fill this entire background with some kind of grass and then change the tiles around. One really good tool for doing that is going to be our fill bucket tool. So if we hit F or click up here, we can switch to fill bucket. So with this, we can select one of the tiles that we want to use and we can fill every single square up with the same tile. This, if we zoom in here, it's going to have a lot of repetitions, so it's not going to look very good. So one simple option we have is rather than just using bucket fill, we can also enable random mode by hitting D or clicking over here. By having random mode on, we can go over to the tile set and select a series of tiles, which will basically compose the list of possibilities that we can fill each square on this tile mapping. So I'm going to port 300 percent for the zoom here. So we can see these tiles nicely. We can select all of these eight different grass tiles with random mode. And then if we hover over here and we can just drag around, you can see this is going to randomly generate some background grass for us. So if we look at these random generations, we can probably see that there's a few too many rocks here. So one way that you can control how often those rock tiles are going to show up is by setting their probability to a lower amount. So every tile by default has a 1 probability. And we can go over to the tile set file in order to customize that property for each tile. So if we go on to craft land tiled TSX, Then we can right-click on any of these tiles and set the probability value. So I was messing around with it a little bit before it. So you can see that these photographs styles have a 0.2 probability. And then these ones on the right, or at least one of them has a 1 value. So when it has 1 value, that's obviously five times higher than a 0.2 probability. So this one would be showing five times as much as the other tiles, which all have a 0.2 probability. And if we look at the tile map and we try to generate that, we can see that that tile, it does end up showing up a lot. So if we want to get a better ratio, then we want to take these and customize the value. So I might take these and set the probability back to 1 for all of them. So you can just right-click on a tile and then select the probability over there. And then for these rock tiles, I will set the probability to something like 0.3. So they'll show up just not that often, zero-point three here. So 0.3 here as well. And Let's do 0.3 for that one in control S to save the tile set file. Now we can go back to the tile map, and this time when we randomly generate, we can see, no matter which random generation we use, we get a lot more of those grass files that have the big pieces of grass kinda sticking up. So if we left-click, that's gonna give us our randomly generated map. Now there's one big flaw here, which is that we don't really have the base tile and this group. So we can see now that no matter where I let the random generation like we're going to get a lot more of those grass tiles without the box than the ones with the rocks, which is a little bit closer to what we want. But we can also see that there are no base grass tiles, like you can see over here. These would be the basic ones. We would want one of these to show up and kind of fill a lot of the spaces. And these are more of the variation tiles. So if we go back to the tile set and let's grab this one over here, will change the probability and we might change the probability back. But while we're randomly generating now, let's set it to 5, which means this tile is going to show up five times as much as these other 1 tiles. Let's go to the tile map. So if we want to select these eight tiles plus this one on Mac, you would use the command key and press here. I'm not sure what the key would be on Windows, but I would try having your selection and then you can try and control-click Alt, Click, shift, click. It's probably one of those or one of the nearby keys. So anyway, with your selection, if you get these nine tiles, you can see that now we can generate a much more interesting field of tiles. And if we left-click there, we have our grass for the town. So if you don't like this, if this is still too much of the random tiles, you can always control or Command Z and go back over to the tile set and then change the probability. So we could make this 15 if we want just to have a lot more of those random tiles and then go back here and left-click, I'm hitting B to go into stamp mode so that we can see things a bit clearer. And that maybe looks a little bit more convincing for random tiles for our map. So it's really handy to be able to fill your map in like this, because now we don't need to do as much manual work. Terrain sets will also fill a similar role in helping us to build tile maps without having too much trouble. So now that we have a base layer of ground here, we can add in some other kinds of tiles. So let's mix in some of these sand tiles as well. So I'm actually going to use this rectangular select tool R on the keyboard. And let's select a bunch of tiles. And this time after you do one selection, if you want to add to it, you can hold Shift down and grab some more tiles. So just add n regions that I want to make sand for whatever reason kn, I'll just take this top right of the map and that can be sand to just grab a few selections. Okay, and now we want to do something similar. We wouldn't want to go back to the fill bucket tool and we want to fill this in with a bunch of tiles. So we can see that although most of the tiles or that main grass tile, not all of them are. So we can actually delete all of the tiles inside of here and then we're going to replace them with a new fill bucket. So I'm going to hit Control X and now we have no tails in there, so it'll be much easier to fill them all in at once. So let's select the tiles that we want for our variation. So on Mac, I'm holding Command down and I'm going to add in these variation tiles over here. Okay, so now if I use the Fill Bucket Tool, we can see that we can get kind of a cool desert over there. Once again though, of course, way too many rocks. So let's go over to the tile set, and let's give some probabilities for these tiles. So I'll give this one a 15 again. And I think that's probably good. So I'll just save it and go back over here. And now we get something much more realistic looking. So I'll left-click and fill all of that. And so this looks okay ish, as far as filling in a big gap of area, It's all right, at least we have some variation, but now we need some of the border tiles to go between these two. This is one of the areas where terrain sets will really come in handy. But if you want to manually add in some tiles, which will get tedious, we can left-click and select a tile that we need manually. So actually, because we're going sand to grass, we want sand on the right and grass on the left. So we select this tile, hit B to go into stamp mode, and then we can just left-click and press and add a few. And for these areas will need a different tile. But down here, we can just kind of fill that in any way where it's basically just going straight down or you can use that tile. So you can kinda see how that will help bridge the gap between our sand and our grass. And a good tile set. We'll have these kind of tiles because obviously if you just go from grass and suddenly to sand, that's going to look pretty ugly and also pretty unrealistic. So you really do want these transition tiles to be part of this. So let's fill in some of these corners just to make it look a little better. So here we have a corner piece, this will be a horizontal piece. And here we're going to need a different kind of corner. I think we're looking for this one down here where it's a grass in the top-left, but in the bottom right, it's actually sand. So we have grass and then sand, sand, sand, and knowing which corners, which is actually how we're going to set up the terrain map as well, just as a hint. So let's add in this one because we send on the right, grass on the left. Okay? And just with that, we kind of have the transition for this part of the map looking a lot better. Okay, so now let's start adding another layer on top of our base ground. So I'm going to go over here to the right and I'm going to choose tile layer. And we could call this layer maybe objects, tiles or something like that. So with this tile layer, we can add an entire object in on top of the ground by selecting all of the tiles for this tree, we can see that because of the size of the tree, this takes kinda like three wide by four tall. And if we go to stem selection mode or B on the keyboard, we should be able to put an entire tree here, but currently we're in random mode, similarly d to turn that off. And now we can see the full tree. So what's going to be nice about this is because we're putting it on a separate layer. If a left-click and add our tree here, you can see that this does not impact the base ground layer. The ground is still there. But by having the tree on a separate layer, the background layer can still be visible. So this allows us to have the grass and the tree occupying the same technical title of game space. But because the tree is partially transparent on the edges. The background tile is going to be able to show through. So this allows us to once again create more interesting maps. So another trick you can use to add a little more variation is to hit X on the keyboard to flip your currently selected tiles horizontally. So if it's facing left and now it's facing right. Okay, So you see the problem there. I was on the base ground layer. I'm going to Command Z to undo. We'll go to the object tiles layer, left-click to put it in. So that's the difference, That's why layers are important. So they can have multiple things showing on the same area at once. So it won't work for a tree like this beak and also use the Z button to rotate around 90 degrees for each pressing busy. But obviously a lot of tiles only work when they are facing downward, especially in these kind of top-down style games. So you can just add in various objects like trees. There's a lot in this craft land tile set. So we could also add in something like a workbench. So I'll just add a couple little random things there. So you might be wondering about a couple of things here. First off, why am I doing object tiles as a tile layer and not an object layer. So Object layers are a bit different. And object layer, you're able to either define regions are points. So like you can drag a box over here and you can give it a name, you can add custom properties to it. So for instance, you could create something like a game over region like, oh, if the character walks here, then you have a game over. So one problem with that is that the Godot exploiter doesn't actually support currently converting that into something like an area 2D. And then secondly, the other reason why I'm not using that, if you do insert tile, so you insert a title as an object. That can be okay. But the thing is, you can only do one tile at a time. So if you have something like a chest over here, you can see when you try to add four tiles as one chest, you'd actually have to do it as four separate objects. And I have to reorder here so that you can actually see the object layer on top. Okay, Let's see tile mode. Select the chest, add a square and okay, so this is now an object, and this is an object. And now this is another object. And this object, which isn't really the intent. If you had a chest, you probably want to make it like animated chest where it opens up. And instead you'd be replacing the sprite all at once. So if you actually use the ghetto exporter, it would come as four separate sprites for separate objects. That's not really what we're looking for. So currently I would shy away from the object layer and just use tiled for basically just creating the background and then manually creating the objects with the properties that we want inside of Godel. So just wanted to be clear about that. So when we do object tiles here, we're really just talking about objects that maybe have collision shapes at most, but they're not really going to be doing anything in this thing. So we'd probably replace this chest with a actual chest object that we've created with could DO nodes inside of Godel so that it could play an animation. 7. 7 Tile Collisions and Display Sorting with Tiled Maps: Another topic I'd like to touch upon here is that when we actually export to our game, we're going to want certain objects. Like an obvious example would be the base of a house or the base of a tree to actually block our player to have collisions enabled. So we can actually put collisions on tiles in tiled and still have that export to could DO success. So we don't need to manage the setup of the tile collisions there. We can do it straight from within tiled. And every time we edit our tile map and export it, we'll also update the collisions associated with those tiles. So for this tree, that would be a really obvious example. We want to go over to the tile map and then choose this tile collision editor. So click that and open it up if it's not already. And then you have tools over here in order to select the collision shape for your tiles. So you can use tools like insert rectangle. And you can see if it kinda click there. It gives us basically just a 16 by 16 rectangle around our object. I'm going to hit Command X to cut that away. Because when you have invisible pixels like here, I think a better tool is to actually use detect bounding box. So when we click this, It's going to figure out where invisible pixels are. So if you have an invisible pixel, generally, I would think that would be a good candidate for a space that you character should be able to walk into. There's no tree there. So your character should be able to move that one extra pixel. So you can also see here that this doesn't account for the shadows because the shadows are colored. So if you want to play around with the shape a little bit, you can come over to the left-hand side. And let's say we want to move the height one pixel more so I can change the height to 14. And then that is going to move that up just a little bit more. So there's other tools here you can use. But I think detect bounding box or just adding a rectangle is going to be pretty good for. In this case, for a 2D top-down game, probably 90 percent of the tiles you need. So I'll click up here. And this is obviously going to be a tile where we want the entire square to be taken up. So I'll just detect bounding box and it gives us our 16 by 16 squared there. So with these, if I saved the tile set and I go back over to the tile map, you can see that now it's going to be showing where the collisions are on our tiles, which is a good visual indication. And when we export over 2 Godel, we're going to have those same tile collisions in our actual game. So you can see how when we build things and tile, we don't actually need to do quite as much manually and Godel. So let's actually go ahead and export these, both the tile map and the tile set to cuddle. And we can open that up and just take a look at how in Godot will have those same tile collisions. So I'll go to File Export As and let's see, the maps goes in the Maps folder. So let's replace that. Yes, to replace. And then tile set, same thing, export as this goes in the tile sets folder. So export, replace. Okay, now let's open up our Godot project. So you might get a message saying that tile map one has been rewritten and is a newer file on the disk. We want to reload that so that we can have the updated version. And we can't really see much of a change when we click on the tile map here. But if we look at the tile set that that's built from, if we go to tile sets and then craft land tiles, we'll look at our tile set. If we came to click over here on the grid and collision mode that we have the collision shapes for those two tiles that we set up exported from tiled integral. So this is also a handy if you later decide for any reason that you want to make some more manual changes in Godel after you've already exported your tile map from tiled. Though I do think it's a better workflow if you just make all of your map changes in one place and then you export when you need to have that updated. So to go ahead and test the collisions of our trees, and let's go copy and paste that player over from the original test map. So go to test map. Let's grab the camera 2D, because I've grabbed the camera and the y soil. So I'm going to Command C and Command V, paste them in here. And let's just cut away of these other objects. I'm going to select this list Control X. And now we can go ahead and run this same. So if we hit Play, run our game and move around, we can see that we can collide with our tree that collision shapes for it. But one problem here is that if we walked behind the tree, we're showing in front of the tree, even though clearly he should be behind the tree branches right now. So that can be a pretty simple fix with this object style layer, we just make sure that that is below our player layer. Now, in this case, when we run the game, it's going to look just fine because we'll be able to go behind the tree in any way that we are not behind the tree, we're going to be colliding with the tree. So in this case, it's just, it works fine. But one thing to note here is that the tile map layers aren't actually automatically sorting, like you're wiser, objects are going to be all of the game. Objects like, let's say, enemies that will be moving around the screen. So what we may run into in the future is the need to create two objects, tile layers. One that is going to sit below the player on this hierarchy on the list, and then one that would sit above. But currently, for this kind of setup where we have collisions down here, it's actually working just fine so we may not need it. But if you run into this situation where it's not sorting, right, you can just manual you hack this sorting by kinda creating two separate layers like that. And then obviously for the characters that do move around the screen and do need to have that y soy it constantly updated. We will put those along with the player and their own Weiser Object Group. So that's a basic look at collisions and tile sorting for the tile map editor. What you can do at this point, if you are going to add some extra of these tiles to your scene is to go through these objects and just add tiles to them as you need. So you can just select the tile and do the bounding box, and that'll get you probably two-thirds of the way you need for most of this. So for this one, we'll just have a bounding box. You can just do the same thing for each of the trees. That one maybe we make it 13 pixels height or 12, even. Whatever you need. You can just kinda quickly go through the different tiles here. So this one, we won't even need to do a bounding box for the top tile. And then when you actually add your objects onto the object tiles layer, and let's get this little tree. You can just verify that everything is good because you can actually visually see those little collision shapes. So you have a good visual indicator. You can basically get an idea of how it's all going to look when you are running your game. 8. 8 Tile Faster with Terrain Sets: Now in this video we're going to be talking about terrain sets, which are incredibly useful tool for being able to draw different shapes of different types of terrain onto your map very quickly, much easier than it is to manually place all of these much quicker and easier than it is to manually place all of these edge tiles when you're going between one type of terrain and another. And another advantage and tiled is that when you're making terrain sets, you can actually set up rules between multiple types of terrain sets. So for instance, you can have grass going to sand and sand going to water. And if you had grass tiles that also transitioned into water, you could add those in as well in the same terrain set. So the main limitation here is going to be if the tile set actually has the tiles that go from one type of tile to another. So if we click on our tile set, we can see our tiles that we're going to be building the terrain from. So we have sand that goes to grass, we have sand that goes to water, but we can't do grass that goes to water because obviously we just don't have those tiles. But if you were able to source them, then you could easily set up grass that goes to water as well. So let's create our first terrain set. So click on this button for terrain sets if you haven't already. So that'll open up the terrain sets window on the right-hand side. And then in the bottom right-hand corner for that there's a plus sign here. So you need to choose that and then choose new corner set. So this type of set is really straightforward. Let's give it the name ground, because we're dealing with ground tiles here. So you have a different color for each type of terrain. So we'll have one for Dirt, one for grass, and one for water. So the default colors starts with red, then goes to green and blue. So I'll use red for dirt, green for grass, and then blue for water. But if you want to customize the colors for each of your terrain, so you can just click here and then choose the color selector up here and customize it. You can also right-click on the terrain in the list and just choose, pick custom color. So if you want to change the name, you can either do it on the Properties window or you can just kinda double-click here to enter in a name. So I'm going to enter in the name dirt. And then we're going to add a new terrain to this terrain set. So I'm going to click plus, now we get the green option. I'm going to call this grass. I'm going to hit plus, and now we have a blue one which will make water. So now we need to tell each tile that we want to be included in this train set. Which corner is which type of terrain? So I'll click on and I'll set up the dirt roles first. So in these tiles, so we have four tiles here. This is one, this is one, this is one, and this is another one. We can see that each of them have dirt in the corner that's the most interfacing. So I'm going to left-click on each of those corner areas and make that defined as dirt terrain. So I'll do this with the other tiles as well. So this set of tiles has three corner pieces where it is dirt terrain and those are the interfacing ones. So I'm going to left-click and you can also left click and hold if you want to kinda draw a line rather than left clicking for each corner individually like that. Anyway, you just need to define and these tiles that the interfacing ones are the dirt pieces. And now let's go to grass. So with grass is green and we click on the corners that have grass. So we can just go all the way around these tiles. So we have four corners you to find. Each tile of course is going to have four corners. So 30 graphs, one is Radford. And although each of these tiles have that ratio, you can see that where the dura is located changes for each one. So this will create a situation where a tile is going to be selected based on what type of terrain it's bordering. So for instance, this time will be selected if there's dirt bordering up here and if there's grass, I think it's like above, to the right and down, something like that. And so each of these tiles are going to be matched automatically in those specific cases. So each tile has a different setup. So these four have one grass in each of the corners and three dirt's inward spacing on these tiles will have grass going all the way around like this. So you can probably get the idea where you see grass, you draw grass terrain set and where you see dirt, you fill it in with dirt corner pieces. And then this inner peace will just be for dirt because of course, it's just flat dirt and it doesn't indicate that there's any other type of terrain bordering it. Likewise, for these ones which are just variations of that dirt square where there's no other terrains bordering it. We'll just fill those in all four corners as dirt. And same with the grass down here. Because those are just variation tiles. So these can fill on the same bordering terrain such as this one can basically the same tile. So let's use dirt to fill in these corners as well. Okay. Oops. We want grass there actually. And then let's just keep filling in the rest of these dirt to grass transitions. Okay. So now we have the water areas. So what borders? So where we see dirt, we draw a dark corner. So for that one, that's going to be these four corners. And then the inner pieces are going to all be water. I believe, and then it's too dark all the way around here. Okay. And everything inside is going to be water. Okay. And this one is like for water there and then everything else surrounding it is dirt. Okay, So with these rules setup, we're able to really easily draw a quite complicated pieces of terrain. If I have everything setup right, it's going to be kinda crazy how fast you can actually just come up with a random river manually done and not needing to worry about drawing in all of the edge tiles. So let's go back to tiled map. I'm going to click on ground and we have our three terrains setup. So just make sure you're on the ground layer so that we're actually overriding existing ground tiles. So if we want object titles and we tried to use these, it wouldn't actually work because it gets were trying to draw terrain matching tiles that aren't actually there. So if we're on bass ground, we should be able to actually set something up here. So let's use water and I am going to just kinda draw a river, I guess. So let's go up here to the top, just going to left-click press and hold. And let's just bring it around wherever we want. And you can see like in an instant, we've created a river and all of the tiles are perfectly matched. So to do that manually would have probably taken five or ten minutes. So you can just see how powerful terrain sets r. And now we can add some grass to this dirt. Just click on grass wherever you want to add grass, draw around. And here we can see that we've added in a patch of grass. Now, note, since we created all those other possibilities for the center grass piece, that when we draw a bound, it's going to be randomly selecting those. And I believe that selection is still going to be based on the probability we've set for these tiles. So if you want it to show up less often, you can just select one of these styles, go to probability and increase or decrease the probability depending on what you need. So In the previous video, we set this main grass tile 215 probability. So that's why when we draw graphs, we see a lot more of this one, the one that has no Vox or any other grass pieces sticking on top of it. So if we try to do grass bordering the water and I click there, it's not going to work because there's no rule setup for grasp bordering water. So this would be where you would just need more tiles created. And then you can go into your terrain set and you could create grass corner with water corner terrain set rules. So unfortunately, this tile set just doesn't have that. So that would just be extra artwork that needs to be created in order to make that a possibility. So just create grass around here. It's going to replace everything else with dirt because that's the only terrain set that we've set up that can border grass with our basic rules. So likewise in reverse, if we create water and we try to go through the grass, it's going to replace it with dirt because that's all we have rules setup for. So you're just limited by your artwork selection basically. But you can add in a whole bunch more terrain. So if it just click here a bunch of times, you can see that it's possible not to just do two or three, but you could even go up to six. And it would be possible to have a tile where you'd have grass in one corner and maybe snow in one corner, water in one corner and dirt and another corner. Something like that. As long as there's the artwork for it, you can create a train set for it and it can make sense and you project. So we can create one more terrain set from this tile set file, because there's these snowy options down here. So let's hit the plus button and create a new corner. So this would be the same thing. I'll just call this snow ground here and the red can be snow here. Then I'll add another one in. And this will be snowy graphs. And then the last one can be seawater, something like that. So just like before, we just need to set up the rules for these tiles. So let's start with the snowy grass. I'll just do this real quick, okay, and we'll get these alternative centerpiece tiles just for some nice variation. So if it wasn't obvious, if you have two tiles that have the exact same terrain site rules on it, then it will randomly select between the tiles that have this same matching corner rules. So let's choose snow here and get these inner snow pieces. This one has four for those four tiles. The variation centers, snow tiles. And this one with snow on the outside, grass on the inside. And now we need snow with the water. So it's basically the same matching rules as the ones up here. But of course that's going to be tile set dependent. So let's see ahead for water in the center. So let's see the same thing or water center. And then snow everywhere else. And just filling in the other snow tiles. And I missed one right there. Okay. So with those rules, we can just create with a different type of terrain. So when we select this snow ground tile set, even though we're on bass ground, it's not gonna be able to draw anything. If we use the ground tiles, then of course we can draw there. The reason is that the train set can only work if it actually recognizes one of the tiles. So for us to start drawing with the terrain set, we'd actually need to create some snowy ground first. So if I was to go to a tile sets here, and let's say we wanted some snow down here at the bottom. Then I can draw some snow squares over the base ground. And now that that's there, we can go to terrain sets, select our terrain type, and we can start drawing on top of it. So as long as the base tiles are contained within our terrain set, will be able to draw on top of it and create our interesting environments. But as soon as you get to the edge of something that does not exist there, it has no rules, then you're gonna be kinda stuck. It won't actually know what to do. So the limitation once again here is that if there is no rule setup for the specific type of tile you're trying to draw against, then the train site won't know what to do. You have to define rules for the type of tiles it's going to be bordering an auto selecting tiles against. So what you can do at this point is to just take your terrain set either the normal one, the grassy summertime or the snow tiles and just build a base map that you would be happy with using as we start to add more objects, houses, and the likes to our game map for the Godel game. 9. 9 Building Our Village ~ Collisions, Bridges, Level Scenes, and Camera Limits: So in this video, I'm going to be continuing to work on this game map. And you can kinda follow along if you'd like. Mostly we're just going to be retouching on some of the points we've talked about earlier, adding more objects to the map and making sure that collisions makes sense. So for instance, right now there's no collisions on the water. We want to make sure that our character won't just be able to walk across the water randomly. And we'll probably add bridges and that kinda thing. So as I mentioned, the water does not have collision shapes. We can take a look at our trees and see that's what it looks like with a collision shape. So let's add some collisions to the water tiles. So if we go over to the craft land tiled set, we can define some collisions on the squares. Okay? So when you want to add collisions to the water, you can click on the tile collision editor and then click on the title you want to edit. I'm going to make sure that this window snaps to the right-hand side by dragging and dropping it. So here on this tile you can see that there's a little bit of ground that the player could potentially stand on if we wanted to allow it. Another option would just be to drag an entire box around our script. So if we try to do something like insert a rectangle for the collisions on this tile. You might notice that it's snapping to basically the 16 by 16 pixel interval. So if I try to click over here and drag a box, if I let go top left to bottom right hand corner, it'll give us our 16-bit 16 pixel box, but it's not really allowing us to go in between. As you can see, the snapping is 16 pixels interval at the moment. So you can actually set up some snapping hotkeys to reduce this to either. If I do Shift H on my keyboard, which is a custom, then it looks like four pixel intervals or shift nine, which I have setup to buy pixel intervals. And this will allow us to draw more interesting shapes like this. Going all the way around. And then they're creating our collision shape and allowing this area to be left alone. So to get that setup, you gotta go to tiled preferences, keyboard, and then you can search for snap. So here you can see I have three custom shortcuts setup snap to pixels. That's one pixel at a time. Snap to fine grid, which breaks down the snapping to four pixels out of time could be pretty helpful. And then snap to grid shift num seven, which I believe is the default. That's where we get these 16 pixels snaps. So you can use whatever shortcuts you want. You just got to click in there, give it a custom key. So if I double-click here and I do Shift and then eight on the numpad, that would be how I would set that can see the shortcut updates there. And then we hit Close. So for this particular tile, I wanna do it kinda like it was before. So I'm going to do shift nine, which is Mickey combination for snap to pixels. This is probably better than doing no snapping at all, which was a fourth option. Because in Godot, everything really kinda snaps to those one pixel intervals. So we want to be consistent with that. So I will say this area is going to be allowed for walking and everything else is not. So going along with the polygon tool, that's P and the collision editor, allows you to draw your own custom collision shapes. So now we can hit Control S on that. If we go to the tiled map editor and we can see very nicely that of these automatic collision shapes have been added. And for us, which is really nice and satisfying to look at. So now we just need to do that for the other tiles which are flat on them. And yes, it can be a little bit tedious, but once you have it set up, you just don't need to worry about it anymore because whenever you have these tiles, they're going to have that collision shapes added to them. So let's do something similar over here. So I'm going to use the polygon tool and avoid this little block with the sand on it. But everything else is going to be water. So we're going to prevent the player from walking there. And whenever you're creating these collision shapes, it might be a good idea to just test by Vx porting over the Godel and making sure that there's collision shapes show up here so we can see these shapes we just added. They still allow for these corners to work. So for this one, since we're still using the polygon tool, we could create something of a diagonal edge here. It doesn't need to be exactly pixel perfect. It just needs to make sense for your game and you can always come. We added these if you need to. But just approximating the shape there, of course, you could do pixel by pixel by pixel, but that might become a little bit overkill. So let's do something similar over here. I'm going to draw a line and the bottom right hand corner and everything else gets filled in as the water. We can check that over on the tile map as well, making sure our collisions are being updated here as well. And now let's keep going with these other tiles. If you just want a quick and dirty towels, you might find the rectangle tool to work a little smoother for you. So you can just drag a rectangle, something like that and call it done if we wanted to. We can also add in multiple rectangles, so we could do something like this. So now there's two rectangles and this tile serving as the collision could even do three. Of course. So that could be fine. And we can see if we can find any of those tiles being added here. So it's just gonna be kinda up to you about what you wanna do. Getting rough approximations of the shapes you're trying to. Allow the player to walk on and what you're not. And every so often you can just switch over to your map and just kinda see if you can find some of those tiles with the collision shapes added in and make sure it actually makes sense when you're looking at it. And later, of course, we'll test it in the actual Godot game and just make sure our player doesn't get stuck anywhere. So I'm just going to keep going here and adding in collision shapes for all the tiles we need for awhile. Yeah, sometimes for simplicity sake, just using a rectangle box, just be the easiest and probably also the least likely for your player character to get stuck on, rather than having weird angled collision shapes. And it's hard to go wrong with a rectangular box. So a good test to make sure you've covered everything is going to be to look at your generated map. And then just to make sure all of these water tiles have their collision shapes added in here. So as you can see, this is going to make it really easy when we switch over to Godel, all of this water is just going to be blocked out nicely. And now character will not be able to walk on it, which is kind of the intent. So the next thing we want to add to our map is a bridge that can go across the water. Nl players able to walk across the bridge. But we also need to have the water tiles below it as well, so that the pixels that are invisible on the bridge will still show the water tiles underneath so that it looks correct. But you can see that these water tiles have a collision blocking the player from going across. So if you have two object tile layers, the water will block the players movement, even if the bridge object style would allow the player to move. So there's a few ways we could solve this. One would be to have separate layers for the ground and then ground that we want to ignore collision on. And then again DO what we could do is take that layer that we want to remove all collisions from, click on it and then go down to collision and just remove it from layer one, which is the main world layer in good 0 by default. So if the player is looking to collide on layer one, but we remove the tile map from L1, then it won't collide with layer 1 so that the collision shapes on those water squares that are here are going to be completely ignored. So that would be one option. The problem is that then every time we export over to Godot will have an extra setting we need to change and we might forget to enable that one at the times that we make changes to the map. Another alternative is to create a, another copy of these water squares, or really the tile map in general, where there's just no collision setup at all. We can reuse the same image in order to do that would just have no collision version. So in order to create a copy of this tile set will just reuse the same image. And then we just won't add any collisions to that version of the map. So I'll do a new tile site here, and we're going to base this on the image, of course. So let's see an art. Let's go craft land, cropland dot PNG. And we'll embed it in the map because we were just expect that to be there, the craft land dot PNG. Let's do a Save As, and then let's give it a different name. So I might start the name here with NC for no collision, or you could just put no collision, whatever makes sense to you. And let's save that in our projects for the tile sets, okay, and now this time when we click on each of our squares like the water, there's no collisions setup for them. So this means we can use it in place of the regular tiles. Have it look exactly the same, but with no collisions, even if we put it on this same base ground layer. So in C craft land, Let's go ahead and select those squares over here. So this is going to be a bit manual. I'm not going to bother to create terrain sets because these are very specific cases where we're going to need to remove the collisions here, like when we're building a bridge. So I'll just use manually putting it in for now. So just like that, we've removed the collision here and the play will be able to walk across here, whether we have a bridge or not, but we want to add a bridge so that it actually makes sense. So on the object tiles layer, I'm going to take a bridge tile down here, whatever you want to use for bridge. And then I'm just going to draw over the base ground tile layer by using the object tiles layer. And you can see in order for a test statically look correct. We have the base ground tile layer still below it for visuals. But now the collisions are removed so a player should be able to walk across this. Of course, when we actually export to grow, well test it. So let's add a couple more here. So let's adjust the tiles again. Over here we'll add another bridge. So I'm just going to replace those tiles and the same way. So let's grab this one. And now a couple of the normal water tiles and the bottom one. Okay, and now this should be a path that we can walk across. So object tiles layer, Let's grab the title we want to use for building a bridge and build a bridge across it just like that. So as long as you can check and see the collision shapes, which it's visually indicated, then you can be reasonably assured that the character will be able to walk across. So just A couple more spots for the bridges if you need to. Let's see, I could do one over here. So let's add and make sure you're on the right layer as well. So base ground because I'm based ground. Okay, so we have that tile k a few water tiles, and now we need the corner that looks like this one up here. But we also need one of these and this one finally, so now with object tiles layer, see where we want to build a bridge. So we just build that across just like cell. Of course, always export, test it with your actual character in the game. Then we're just going to need one final bridge over here. So it's pretty easy to figure out which ones replace it since you can just visually see the copy. So you just have to match the tiles. And then this one, I'm not so sure about this one. No. Okay. Here we go. It's this one. Okay. And it looks like there's no collisions here, so we'll build our final bridge. Now technically I am using the NC craft land tiles over here. So for the bridges are probably actually want to replace those with the normal craft land titled ones. It shouldn't make a difference because we're going to include both tile sets in the export. But, but unless I'm specifically going for a no collision version of the tile, I'm going to try to use the craft land tiled set just to be a little bit more consistent. So just gonna go over here with the normal version, the craft land tiled version. Okay, and then there's our four bridges. So we can export this over to Godel. So export as okay, we save the map under maps. Yes, and we're going to export our tile sets, both of them in the tile sets folder. So now if we go back in here, we can reload. Okay, so here we got the problem where It's looking at the wrong folder for the image for our craft land dot TR. Yes. So I think what we might be missing here is the project root property. So I'm going to add that in and that of course to go from the tile sets folder to the view is dot slash two dots slash two dots. Save that in there. And make sure that that is actually set for all of them. So same thing for the crop land title set and then yeah. Okay. And then let's re-export those. And it looks like the no collision one needs to be re-exported. So for right now I'm just going to, I'm going to trash the tile map and then we're going to re-export it. And same with the no collision version. So let's save that. Let's go back over to tiled. Let's export this. And let's open this up again. In good DO double-check a fixed dependencies. You can make sure that it targets the crap land PNG image if you need to. But if you set up the project root manually, then you shouldn't need to do that. Okay, so now it's seeing it correctly and as you can see, there are no collisions here, which is what we would expect. So let's export the tile map. Again, export to get 0 as a map file. Okay, now we have it in here. We can open it up. And now we should be basically good to go. So because the base ground was composed of multiple tile sets, technically speaking, in a tiled, it needed to export one tile map for each one, but this should work just fine. Another option would have just been to an piled to put all of the tiles made from separate tile maps on their own layer. So we could have done it in C craft land layer, but it shouldn't be required. Okay, so now in Godot, because our tiled map is going to be something that we're going to be exporting. We may even have to delete it and we export it entirely if something goes wrong. I think it would actually be better if we embed this tile map as a scene within our overall level scenes. So then for any Godot objects we want to add to the final level, like the player or the camera. We won't be deleting those every time we re-export the tiled map or have to mess around with this file. So in order to differentiate between the maps which are going to be the visuals and the base underlying collision shapes for our level. And the final thing with everything else included like cameras and any extra scripting we need to add. Let's actually add another category to our project. So I'm going to call it levels MOOC directory. Gonna do new folder. We're going to call it levels. Hit Enter, and then let's create a new scene here. I'll right-click it to new scene. And I guess we'll give a prefix to each level and make it really clear what's what. So I will call this level village, I suppose, and hit Enter For. Okay. So in this, it's going to be a new 2D scene, just renamed the node, their village. And let's drag the tile map one into here. So this will be our visuals and I'll actually manually set the transform in the inspector so at 00 for the position. Okay, so now we have our visual map here. And we want to add an a copy of the player. So I'm going to drag the player scene into here, wherever we want the player to spawn. Let's put him right over here actually so we can test those bridges. And then let's add a camera. So camera 2D. And then this player, we're going to want a transform, a remote transform 2D. Then that is going to point at the camera. And then the camera's going to be set to current. And then if we want, we can set limits on the map. So on our camera I'll go to the editor tab, check limits, and then limit. Let's set some limits. I will make it something reasonable. We can see like negative 300, negative 300, and then six hundred and six hundred, okay, for right now. And now we just need to take these yellow lemons and actually fit them to our map. So I'll press and hold on the right limit and just drag this over to the edge present hold on the bottom limit and drag that to the edge of the map. There, the left, I'll pull that in. So right now they're at about Pixel 0. And now the camera won't be able to go outside the bounds of our map. So sort of pretty easily, Let's hit Control S, and let's actually run this scene. Sorry, character can move around. Let's see if we can get across the bridge. And as you can see, we can not. And I think the problem is that our character just has too big of a collision shape. And also the characters collision shape doesn't really make sense to begin with, because really the only thing that should be colliding with stuff should be the feet area. So if you think about a character vertically, your face wouldn't be running into the bridge or the water, but your feet would need to walk across it so the collision shape needs to be shrunken down. So let's go into the player scene and let's shrink that collision shape. So collision shape on the player. Just going to adjust the size here and I'm going to move it down to the feet area. Okay, save that. Let's go to the village level. Let's run the scene again and let's see if we can walk across the bridge. And there we go. Our character can walk across the bridge but cannot walk into the water. And I didn't mention it. But in case you're wondering why we can see the collision shapes right now, there's a sudden you can enable for that and get L. So if you go to debug and then you check visible collision shapes, then you can see your collision shapes whenever you're running the game. So that will help you for making sure that your maps working correctly. So if you're not able to walk across the bridge, you might see the collision shapes there. And that would give you a good indicator of why you can't. So this bridge were able to walk across it as well. This would be bridged down here and we can just test these one at a time, okay, and then we have walking across that bridge as well, though in a nutshell, that is how you can Use collision shapes in tiled and then have a separate version for when you actually do want to allow the player to move across it. And just as approach to that would be how you could do a secret fake wall as well. You could normally have one of those tiles be blocking your player. But then if you want to create a secret way, character can actually walk through it, then you can just create a version with visually, it looks like it should be a wall, but then there's no actual collision shape so your player can walk straight through it. 10. 10 Building a House Interior: So in this video, we're going to create an indoor environment using a different one of our tile sets. So in art we're going to be using the super retro world anterior pack. And we'll just create an inside to one of these houses that are character can walk into. And we'll set up a level transition as well. So let's go over to tiled and what we're going to actually start a new map here. So this map will be quite small. Ia will put it at, let's say, 25 by 20 height. Just start and we can always customize that later. Let's save as. And this time I'm going to go into the maps folder and I'm going to call it map village house 0, 1. So we might have multiple village houses. So numbering them can be kinda helpful here. Let's save that file and we want to use a different tile set for this. So I'm going to add a new tile set and I'm going to use browse to go to the art of our project. So we're going to look at super retro world interior, grab this atlas 16 pixels, open that up. We're going to save this. So we need to save our tile set now inside of tile sets. So this is going to be, let's actually use in naming convention. I'll call this tile set underscore super retro interior. Guess, save that in there. And here we have our artwork that we can use for the inside of our little village map. So because we have new maps and new tile sets, we of course now, okay, Well first off, I'm going to resave this because I typed that name and wrong. So add the E there, okay, and save that. Now we can just go into the ghetto project and delete this extra one now, because we have a new tile set and we have a new map, we need to add in the custom properties to both of them for the project roots. So add property, okay, and I'm going to call this project root as a string, save. So like the other tile sets its dot slash, two dots slash two dots, meaning we jump up to directories. So save that. And then the house map, let's add the property. Project Root, dot slash two dots end, and then hit enter. Okay, now let's just jump over to the atlas and let's put in the tiles we want to use for this little interior. So obviously, since this is inside the house, the way we build our tile map with these styles is going to look a little different. So let's start by adding in a wall. So I'll just put that over there. Okay, next, let's add in some base wood floor here. So I'm going to use this and go around over here where the edges of the ceiling and also kinda what would be the border of our room. We can use these tiles down here. So this is kinda the rim around the ceiling and we're just kinda go down like so. Of course, it's really going to vary on which tiles that you're using, how this all fits together. We can just have a pretty simple, basic room here for right now. And then I think we just did this piece up there. Okay, So we have kind of a random interior. So I'll rename this tile setup here and I'm going to call it waltz. And then we'll add a new tile layer called ground. And where the ground is, I'm going to cut that away using the rectangular select, grab these tiles, Command or Control X, go over to ground, control V, paste that in there. So now these are two separate layers. Another thing that we probably wanna do is add collision shapes. So under the title set, let's take these squares and actually give them a collision. So for these edge tiles, It's kinda up to you if you want to just add a collision to the entire square, or you just want it to be these corner pieces where there's actually visible pixels. So currently I'm in find Select mode. I'll just switch over to pixel snapping mode. Once again, if you don't know how to do snapping, go to tiled preferences, keyboard, typing snap here, and then you can choose Key bindings for your different snapping mode. So I'm using snapping to pixels for right now. I'm just gonna kinda roughly go wherever I see pixels representing the edges of the wall, I'm going to add in our collision shapes there just to kinda get it roughly there. And I'll just do that for all of these. Maybe we could even try no snapping mode. So make that shift plus number six. Let's try that. Just gonna kinda keep going through this semi tedious process. But once you have it set up for each of your tiles, you don't have to really do it again. Since whenever you export any of your tile maps will be already setup and therefore you, okay, and then we can always check out our map and see our collision shapes. Since that's definitely going to block the player. We also need to add them for the wall squares as well. So that'll be really easy. We can just click on these and do bounding box. That's just going to fill in the entire wall square. So I'm just going to do that for all of the colors and advance over here. I'll do these brick walls as well. Okay, great. So our collisions seem to be working over there for the house. Might be cool if we added kind of like a separate room. So what I might do here is kinda make these walls here swing around rather than going straight down. So that's kinda grab the eraser tool and get rid of that one. So we do probably want there to be these colored walls going down here as well being consistent with the whole room. And now we can keep going across here. Then this one is going to be empty. We can grab all of our bottom ones and move them down. So I'm going to Control X them and then Control V, paste them in something like there. And then we get the left side over there and can have this come up to there, then our corner needs to swing around. So I'm going to use that peace king and just keep going that way. Now let's grab some ground tiles. So just filling that in there, there. Now we've kind of built it so that our character can kind of walk outside of the room now by going over here, more or less. Maybe we'll just put a little staircase in there. And and we'll see off the wall on the right side. So we're kinda need it to be like this. Then we need the area with the player walks in so we can delete one or two squares right about there. So what our ground tiles there? Now we probably need some objects in the room, so I'll add a new tile layer in, and we'll just call this objects. You're gonna put that below the wall, of course. So if we want to add something like a dresser, we can pop that in there. Oh, actually does this go on top of the wall? Okay. I think I had the ordering on. I think objects does go above walls, so the object shows in front. Okay, and we need to keep that in mind for the Z ordering as well. So these objects, of course, they don't have a collision shape. So we can jump over to tile set and we can just add our collision shapes wherever we want them to be. I'm still in Snap to Pixel mode, so I'll just keep doing that. Just make it kind of precise for these objects. And then on the map, you can see that's going to block our player's collision as well. So just kinda take some of these little objects and decorate the room more or less. I guess on the wall we could have sex and potions and maybe we have a bookshelf. You can always hit X if you want to swap it horizontally, or z if you want to rotate 90 degrees out of time. But of course, with these top style games, most of the sprites, you can't really rotate like that. It just doesn't make sense. It has one perspective that really works by swapping horizontally will totally work. So it's out in a little table here as well. Some chairs, I guess. So the table on the bookshelf, we probably want to have collisions. But for something like a chair, generally you would like your player walk on to the chair. So you may or may not want that to have a collision shape that depends entirely up to you. So let's add the collision shapes here. So collision shape, adjust this one to make it consistent with the one below it. Trying to basically make a rectangle that goes straight down, not that it kinda zigzags, making these edges consistent. Okay, and now we need to do the table. So I'll snap to wherever we have actual pixels. No, we can go straight down here. Okay, it looks consistent. Let's actually cut the part that has the leg. So I'll pull up to their clicking on this one, seeing that they're equal with each other, we'll make the collisions nicer. Okay, let's do that. Okay, and there. And we also need the middle pieces as well. So that one's going to be a bounding box, then we have that. Four from the left side. Four from the right side. Yeah. Okay. And we can always verify by looking at our little thing here. Okay, We can see actually I was off by one pixel there. So let's go back over to the collision shape. We're going to use the Select mode. And I'm going to stretch this out one more pixel to the left. And then we have a nice square around our table. So if all your titles add up to a square, that's usually going to be good. Now if you want to have something like a rug under our table, are under our chairs and we just need an extra objects layer. So I will call this objects low, and I'll make sure that this is below the main objects layer. So I can put a little bug there if we want. I'm actually not sure why you'd ever rug under a chair. So let's not but maybe kinda towards the entrance we can have something like this. We can make our bug a little bit wider by reusing the tiles. And it's actually make that one more. Okay, This is looking kinda cool. Now let's get the left side and the right side. Save that there. So for the entrance, I'd like to actually have kinda like a little shadow indicating where the entrance and exit is. So I'm going to draw here, but if we hide their walls layer, you can actually see I accidentally drew those onto the walls layer, not the ground. So I'm gonna go to ground. I'm going to put in these shadow tiles on the bottom left there. And I'll go to waltz. I'll hit E to go into erase mode, and I'll erase those extra ground tiles. So that can be that. Let's go into objects and just said in a couple of more random things in the room, maybe some potted plants and a window would look good. I'll put it on the low objects so that on the high objects can put these little cute curtains. So let's have those decorating the window there. I imagine that's kinda how it's supposed to look. And you know what, maybe maybe we want a little chest over there in the corner. Let's add that in there. Okay, Now just gotta kinda add collisions for those different objects. So our chest is going to need a collision shape. So do the rectangle box. Okay, Let's see, we added the TV and there. So let's add these in. And whenever you save, you can go back over here and make sure you got it. So these plants do not have collision shapes. So we've got to do that as well. Give me the top doesn't need it. And for the bottom we can just bounding box. So just bounding box, the bottom tiles and just get that quickly added in there. And we can do that for these little potted plants as well. Okay, and now when we go back over to the map, it looks like our collisions are roughly correct. So note that entrance here isn't going to have a collision and the staircase isn't going to have a collision either. So what we would do with these is we would add an area 2D and make it kind of a level transition area where when the player walks and here we move to a another level. So we're going to have that same kind of thing for entering these maps. So when our character walks roughly here, on our village level, we're going to be able to enter house one. Maybe we'll do it over here just because it's closer. And then that's going to teleport us to this map. And it'll be able to walk around. And you could go a step further by creating like a basement level. And then this area can teleport YouTube that area as well. Same process. 11. 11 Placing Level Switch Triggers and Spawn Points: In this video, I want to talk about adding area to DES for level transitions on to your map. And also adding in positions where you can do things like have a character spawn onto the map, how we can set that up as something we can reference. So specifically for this part of the video, I want to show how you can do that using objects inside of tiled. Now I'm not talking about tile objects. I'm actually talking about a object layer. So if you go to the Layers window and sort of tiles and add a new object layer to your map. We can just call this, I don't know, actual objects for lack of a better name. And then on this objects layer, you'll notice that it gives you different tools for being able to add things like areas to your map. So if you want to add a area 2D, usually you would use a rectangle shape for that. So with this rectangle tool, you can add down here and just left clicking and then dragging a box, the exit to this house. So in order for this rectangle, object to convert to Godel, you need to put in the area type, area 2D. The other option is node 2D. Those are the two types that can be exploited with the title to Godel plugin currently. So the area to D is going to have a collision shape with this size and shape. And we can give it a name as well, like entrance that will make it so that when we export it into Godel, you'll see this as the main name and then it'll have a collision shape right under it as we would expect. So we could also come over here and drag a box for another area and we could call it downstairs transition. I don't know that you have to remember a type area 2D. Now the other option would be to have a position. So we could a little box here and call it a node 2D. So the difference is an area 2D is going to have a shape, but a node 2D is just going to be a specific point inside of here. So we could call this enter house location. I'm going to hit enter. Okay, So we have these now on our actual objects layer. So if we go up to File and Export, we can bring these over ticket L. So in the Godot project, I'm going to reload the scene and you're going to see our area to these added in as well as the node 2D. So the node today you can be a specific position where we could spawn the player on top of when he's already entered the house from outside. So basically create the player at this specific location. And then this entrance shape down here. This can be the exit area. So if the characters inside the house and walks over to here, then we go outside or over here. We can have it go down the staircase as well. Now it does look a bit like for whatever reason the area 2D shape here didn't really export perfectly. But any case, I want to show a big flaw with how this is implemented currently, which is that if you're going to be adding in these kinda area to DES, to your scene. I would think you'd want to attach a script to them to have things trigger, right? So we have the entrance. When the player walks on the entrance, we want something to occur. Now we could add this at the level seen, level, our hierarchy and just have like the level village take care of everything inside of the village, all of the nested sub nodes. And we could do the same thing with this house so that we don't need to attach a script to these area to DES. But I think it less messy way of handling the code rather than to have one root node handle everything. What actually be to have different scripts attached to each of these area to these. And it can send out a signal that our game can respond to you to transition the player from one scene to another scene. So these area two d's will handle the code and responding to the player entering it, send out a signal with the player that entered there and the location that we're going to transition into. And then possibly some global game code can handle moving the player from one scene to another scene. But the big problem of doing that with how this exporter works right now is that if we attach a script here in Godel, but then we re-export the map. It's going to lose reference to all of their scripts. So if I take this entrance dot script and I drag it onto this area 2D, you can see we have this amazing script here that does basically nothing currently. But if I go back into tiled and we export, even though the areas have the same name, they're in the same location when we reload Godel. Oh, look at that. We lose our script. So I think the better way of handling this currently, as everything set up is that rather than putting in the area two Ds and tiled and exporting them, you can create different nodes on your level seen that are separate from the map itself, but that have scripts attached to them. So that when you ve export that level, it's not going to mess with anything for this trigger. The only thing is that if you change the positions of things on your tile map, you'll have to manually come into your level scene and readjust them, move them around. But I think that that's a small trade off in exchange for not having to reset up your scripts. And customize any variables that you might expose on the inspector for those different objects that have scripts running on them. So enough of that ranting. I just wanted to show that you can do that. But currently I'm not actually going to do that. So I'm gonna delete that objects layer. We're just going to use tiled for creating the maps and creating the collisions. I think that's what it's best for. So that's where we'll leave it. So if I go File Export here, we can reload our scene, the map house. So to set up a level for the house map, I'm going to take this village and I'm going to duplicate it. Right-click duplicate. And let's call it level village house 001. Just keep it consistent with the map names itself. So let's duplicate that there. And now we can open up the level. We're going to get rid of this scene node. And we're going to put in the map of the house. So let's get that in there. Move it up to the top, click on it, and reset the transform position to 000. And perhaps we don't actually want a player in the scene. What we can do instead is when we enter the scene, we'll create a player with the camera at the location it needs to be. So we will kinda setting up, we'll have a little note here, a position 2D where we can spawn our player. So I'm actually going to delete the player here. And we're going to delete the camera 2D as well. And we can get rid of this trigger move level for now as well too. So what we're actually going to need is just going to be a position where we can spawn the player depending on where they're entering this house from. So rather than having our player always exist in the scene, what we can do is we can create the player when we enter the scene, either from loading the game or by transitioning into this level from another level. So we can create some spawn points for that to happen. Okay, so to create a list of the different places we can have a player appear inside of our scene. Let's right-click on the village at a child node. And I'm going to give it a node 2 D. So this node will just serve as a list basically. So let's start by creating a list of transitions. Now before we add an area to D2, this transitions list, I want to double-click on our area move level scene, which is in triggers. And here you can see it's just the area to D with a script attached to it, the area move Level script and a collision shape. So for the collision shape, I want to right-click on it and make it unique. If it's not already, that if we keep using this scene around the game, that it's a unique collision shape each time. So if we stretch it like this, it's not going to affect any of the other collision shapes, but it will have its own thing each time. Okay, now we just need to put a copy of this in our level. So I'm going to take the area move level, I'm going to pop it in right about here. Okay? It looks like also the base transform here is not zeros are 0. So back in the main scene, I'm going to do transform and let's reset that to 00 so that it appears up here. So we can see now that because this trigger move level as an instance of the area move level, it automatically reset to the defaults. So I'm going to hold Alt and move this down to here. Holding a vault allows us to grab the right one from the stack. So we position it down here. I'm going to right-click on our area move level trigger and choose editable children. And then we can click on the collision shape and adjust the size and shape of it. So I'm going to do so kind of like that. And we'll click back on the trigger, move level and move it right around there. Now I kinda want to name these appropriately so that we know exactly what each one is trying to do specifically. So I'm gonna double-click on the name of this area and I'm going to call it exit front door because obviously this area is the exit using the front door of the house, going back to the village map. So having a name like that just makes a lot of sense. And I'm also going to duplicate this here. And I'm going to move this over to over here. So I'm holding Alt down once again. So you see how I selected exit front door to when you hold it all down, it guarantees you move the one that you have selected from this stack over here on the left. Now let's take the collision shape and resize it. So you can see that when I duplicate from an existing item, it doesn't make a unique version of the rectangular shapes. So even though I tried to do that in the main scene, we still have to right-click here and make it unique for the collision shape. So another option we could have done is just to drag a new area move level from the file system onto our sane. I think that would have made it. So we don't have this duplication thing, but it's a pretty minor thing. So let's just resize this so that it fits our square right around there. And now we can rename this to be stairs down. Once again, making it really obvious which area this is. Where are we transitioning to? We're going down and we're using the stairs to get there. So when our character comes from outside the house, into the house, then we're going to need kind of a spawn point right about here. And if we go from downstairs, upstairs, we probably want to position our player to appear right here or so. So we need to create some position two d's that we can spawn a player at when they enter the house. So let's create another stack on our village. I'm going to right-click Add a child node. And this will be a node 2D. Going to rename this node. You can call it anything you want as long as you're consistent about it. So I'm going to call it spawn points. And now I can right-click on this and start creating a list of physician Tuesdays. So if you type in position 2D, you'll get this node. It's basically just a node 2 D that has a visual indicator of the exact position on the map. So it's nice visual. So let's create that. Okay, and then this should pop over at 000, I believe. Okay, So now if we once again hold Alt down half position 2D selected, and now we can drag this position away from the stack and position it where we want to spawn a player. So we could go right about here. And this bond point could be called front entrance. Originally I would have maybe port spawn front entrance. But because we're gonna be looking for this stack of nodes of adding, it's already clear that it is a spawn point. So let's duplicate this Control Command D, hold Alt down and move and other spawn point over here. So this one we could call dares down, I guess. So it's at the top of the stairs going down. If that makes sense to you, then you can use the same names. Otherwise, feel free to use whatever you want. So if we wanted to go a step further, we won't be doing it right now. But we could also put it in a spawn point for where the game can save and load. So every time the game might load to this specific map, we could have like a book on the table and put this bond point over there. We're not going to be putting in saving and loading right now. We're just focusing on transitioning between levels first, but kinda the same idea. You can put another spawn point in the list. So let's add some to our level villages well, and to make it quicker, I'll actually take these stacks, going to minimize them. I'm going to select both of them and I'm going to copy them over. So command C, I'm going to click on the village, paste them over. Obviously we're not going to use these same locations. And I can delete this extra 10 up there. But we can use this as the starting point. So the idea is going to be, we'd want to make sure that every level has the same nodes and our hierarchy so that we can look for these nodes in order to find these area names. And we can use that for spawning or loading levels where our player should go. So if we're going to be using code that looks into our levels and sees if there is these node 2D names of transitions and spawn points, it's going to be important to make sure that you keep it consistent between the levels in your game. So that whenever you load up a new map may look for the spawn points. And then you see if the name of the spawn points specified is going to be there so that you can load at the front entrance or at the stairs down. But if you don't keep your naming consistent, you might get some errors later on, so just be aware of that. So let's take this exit front door. I'm going to hold Alt down and move this over to here. And this is actually going to be the entrance front door now. So insurance front door and say how serial one. And that's actually be named that I'm just going to call it insurance house, sir. One there's only one entrance here. So I think just specifying the name of the house is going to make more sense that we know exactly which level we're trying to transition into. And then let's take this stares down and let's move that over here. Okay. And then I'm going to rename this to be entrants. How CO2? And I want the size of the shape to be the same as this one. So I'm going to click on entrance circle one. I'm going to right-click on it editable children so that we can get the data from the shaped 2D here. So let's see our numbers. We might actually want to set this to a specific pixel amount. For consistency, having everything kinda snap to pixel. So 16 by eight. And then we'll click down here. I'm going to right-click editable children collision shape. And let's do 16 by eight here as well. And then for the positions of those area to these, let's make sure that it also snaps to a pixel. It's not a 100 percent required, but I think it generally would be a good idea. So let's see 352 and then 229. Then over here, we will take the transform and make it 96 and then 309 just rounding to whatever pixel is closest. I can also see that the transforms of this collision shape isn't quite right. So I'm going to reset that and make sure that these are consistent. Okay, this one's good. Just making sure everything lines up correctly. So let's go back into the house and just kinda make sure that those are also correct. So the transform here is good. And then we can take the extensive, make it 16 by eight. And then for the stairs going down, that should be eight by eight. And then let's just check the transform for them. 362 and then when 68. And then for this one, I'll make it so that it's 192 into 48. Just trying to match everything up to the exact pixels as much as possible. Since our character will move in pixel increments, it just makes more sense. Okay, so now we have the locations here. Let's create one spawn point for our player to enter this map, since this will be our starting map. So let's take this bottom point here and do player and disperse start. Delete this one because we only need one spawn point. And then let's position this over here, roughly where we want our player to be going to check the transform and make sure it snaps to the pixel. So for 87 by 180 one. So now we have all of our position to these in our area 2D is created. So in the next video, we'll start writing some code and actually be able to spawn our player at the correct location depending on if we're starting the game or if we are transitioning to a new level. 12. 12 Spawning Player with Game Manager: So in the last video, we set up some inferences to the house and areas where we can leave the house, as well as creating a spawn point where we can have the players spawning. And then if we check back into the house scene, you can also see the spawn points for when the character enters a house where they should spawn at. So having those points now, we can start to write some code that will allow us to have the player object be created at those locations at the appropriate time. So in this video, we're going to be working on making it so that the character can spawn inside of our starting scene at this player start location without us actually having the player loaded into the scene by default. From now on, we're probably not going to have the player in the scene until the scene actually loads. And our code creates an instance of the player doing the actual gameplay. So there would be several ways that we could have our game create a player for us when we load into our scene for the first time. And one way that I find works pretty well is to create a singleton game manager. And then that game manager can have a function on it, such as loading a level with a player in the scene, and then tell the level to create the player at the location specified by the game manager. So in order to do that, I'm going to create a new folder and our resources, I'm going to right-click and add a new folder here, and I'm going to call this singletons. What a singleton is is an object that you can only have one of at any given time in the game. So when you reference that object in code, it's going to be referring to one specific object. So you'll never be questioning whether it's this property of this singleton or another one because there's only one or there should be only one anyway. So we're going to create this folder singletons. And then inside of here I'm going to be adding in a new scene. So I'm going to right-click here. I'm going to do new scene. And then this is going to be called the Game Manager. So I'm gonna go ahead and hit okay here. So for the game manager, I'm going to be creating it as just a normal node. It doesn't need to have a 2D location in the game world. It's going to be more of an abstract concept. Just going to select the default node, create that. And then I'm going to rename this to Game Manager. So now we can save this scene. I'm going to command S and save that into our singletons folder. And we're going to attach a scripts to it. So this script will be called Game Manager dot GD. You can just hit the attached script button up there, create it. So here's where we're going to write the code. Before we do that, I do want to make this game manager and actual Singleton in our project. So the singleton world load when the game loads. So we can always be sure that we have a copy of this game manager loaded into the game when we're running it. So I'm gonna go to project, project settings. You want to go to this auto load tamped. And then you want to add in the game manager and make sure that it's enabled as a global variable. So you can just choose the path here, singletons, and then you want to go with the game manager dot TSC. And so when our game loads, we're loading up a copy of the game manager seen. So just make sure it's set up like that. And then let's close that out. Okay, So I'm gonna get rid of all the default text over here. And then the first thing we need to have set up is a copy of the player saying that we want to use for our game. So the first thing we're going to need to add in here is an export variable for the player object. So this is going to be a export packed scene, which means we're just going to be referencing the scene to create a copy of directly in the inspector. So export packed seen var player. So now when we click on our game manager, we can specify what that player is going to be. So I'm going to go into characters and we're just going to drag the player dot TSC and seeing right over here. So we have the cosine for the player. And then by referencing this directly, it's really easy to just create a copy of it in the game wherever you need it to be. So the next thing that we're going to be storing is the spawn location. So far, spawn location, and this is going to be a string. So the spawn location as it is, it's going to reference one of the spawn points inside of your levels. So when we load the level village scene, we specify the span location as players start. And then that'll give us the position where we create the player app. The next thing we want to add is a function to load a level. So this would also be used for switching between levels. So let's go ahead and write it function load level. So I'm gonna be calling this game manager function from other scripts in our game. So I'm going to let those scripts kinda determine which level we're switching into and what spawn location we should be using. So that we can specify that as we're building out each individual level and not here in the game manager for the entire game. So let's add in the variable level packed scene. So this would be just like the player and other scene to load into the game, create a copy of it, and then we have the spawn location. So when the level is loaded, we're going to create the player at the spawn location, but you have to wait till the scenes actually loaded before you can do that. So in the meantime, while we're waiting for the level to load, Let's get the spawn locations set in this game manager. So self.age bond location equals spawn location. The next thing we're going to put var error just to see if we get any error messages coming back from this function, we're going to run and we're gonna do get tree dot change Scene 2. And then we're going to specify the level up here. So I'm changing the active scene to a level. So we get reference to our scene tree and then we change the active scene to whatever we specified from this function, the level which should be a packed scene. So next I want to just make sure that any error messages we get, we send that back to the output so that we can take a look at them. For this change s2, a 0 is a okay error result. We're only interested in the error message if it's not equal to 0 because 0 is normal. So otherwise, we're going to print the error message so that we can take a look at that. So now this function can kind of serve as something we can do globally in a sense. So whenever we want to run this, we just do game manager dot load level and pass in the variables. And then we can basically do that from any other scripts now. So next in our village level, I want to attach a new script to the root of this. So I'm going to add here, and this is going to be leveled dot G, D can create that. And of course this will also be on the village house. So we can just go ahead here and add in the level dot G, D to this route. And of course, this would actually be village house several, one as the root name there. So go ahead and rename that. Okay, so basically any level on the game is going to have this level dot-dot-dot script. So things that we need a level to be able to take care of, I'm going to go into here. So to give these levels a type that we can reference, we can write className level. And then you can check to see if something is of type level rather than just checking if it's a node 2D. And then for each of these levels, we're going to need to specify for node paths. So for objects that should be in the scene and we want to specify each of them so that we can reference them in our script later on. Export node path unready var level camera equals get node level camera. So in the Inspector, we're going to reference the level camera. So that's, that's going to be this camera 2D node v here. And then when the script starts, when the game is actually running, it's going to get the node associated with the path here. So in the inspector, it's just a path, but when the game is running, it's the actual node of the camera itself. So if we click on Village now, you can see that you can assign the camera. So I'm going to hit Assign camera 2D. And we basically just need to do that kind of thing three more times. So I'm going to take this line and copy it down below. Copy paste, copy paste, copy paste. So the other thing we need is the list of game objects. So that's this list here. This is a y sort node a may have added that off camera. So if you need that, you can just right-click over here, do add child node and search for why sort. So this would just be a list of game objects moving around the screen like enemies in PCs or the player. And the y sort node will just keep them organized with each other so that they're rendering on top of each other in the correct order. So just like before, we need to get the node of the game objects, why sort when the game is actually running? So we'll do that there. And then we need one for transitions and one correspond points. And you can see transitions over here and spawn points over there. By having these kind of pre referenced in our script, it makes it really easy to grab them whenever we need them. And it will also make sure that we've actually declared them. Because if you don't have any path assigned for these nodes, then this will kinda error out when you run your script. So get node spawn points, and then we just need to go into the script and assign each of them. So assign the GameObjects list, assign the transitions list, and assign the spawn points list. Okay, so we made sure that we have all of those and now we can use those in code. Let's get rid of that bit and this down here. And the next thing we're going to want to have on our level is after we've created the player, we want to attract the player instance. So var player and since, which just means the copy of the actual player inside of the scene and far camera target. And this is a remote transform 2D. Basically, if you recall, it's the object that the camera points at. And we're going to assign this to the player so that we have a follow camera, but we have to create that after we create the player because the player doesn't exist currently. So when our scene as ready as an hour level has been loaded, that's one we're going to spawn the player. So let's do spawn layer, and we're just going to get reference to the player of the game. So game manager, and you'll notice that since it's a singleton, it just pops up here something we can reference, dot player. So we don't need to specify the specific singleton game manager because they'll always be one. So we could just access that directly like this as a kind of global object. So we get the player and we get the spawn location. And then that's how we're going to spend the player. And you'll remember that when we load the level, we set this bond location to the game manager and advance. Okay, so now we need the function for spawning the player. So Functions spun player. We're going to need the player sink. And this is going to be packed seeing that we're expecting. And the spawn point name, which is a string. So convert that name into the actual spawn point from this list or we will try to at least k. So first we want to get this bond point RAM, the list of spawn points if it exists. So spawn point equals spawn points, dot-dot find node. So on a node you can find children nodes beneath it based on a string name. So we're going to use the spawn point name for that, of course. So if we find a note here that has the same name, then that will be the spawn point. So we wanna make sure that there's a valid spawn point. And if there's not a valid spawn point, then we want to throw some kind of error to let us know that we haven't configured our level correctly. So if spawn point, so if there's a valid spawn point that we found, then we're going to create the player, assign the camera and the remote transform to create a follow camera on the player. Otherwise, if it's not, then we want to print an error message. So here's going to be mined. Print error can't find spawn point plus the spawn point name, which is what we referred to stop here. And we're just going to say which level where n. So in level plus, self-referring to the object that the script is attached to. So that should be like village house 0, 1 if we happen to get this error message. Okay, So we have a spawn 0.1. We need to create an instance of the player and then move it to that point. So player instance. And that's going to be this one up here. If you want to make it very specific, you could do self dot player instance and that's going to be equal to play are seeing dot instance. So we take the cosine, that's the player seen stored in our project, and then we create an instance of the player. So you take the player scene that's stored in our file system and we create a copy of it. Okay, then we need to add the player to the list of game objects. So in level village, that's this list here. So keep track of all of our players, NPCs and other objects that should be sorted with each other as they move around the screen on this list, you could actually call it whatever you want. That game objects just seems pretty straightforward to me. So game objects dot add child, player instance. So now that the player is going to be on this list and the level layer instance dot global position equals spawn point dot position. After creating the instance of the player, we move it's location to exactly where the spawn point is at. So if you want to change where the player spawns now, you just have to change the location of this player start. So just moving that around, you can control where the starting point for your players should be on a level. So next we need to create a remote transform for the camera to follow and then assign the camera to be actually looking at that remote transform. So let's create the camera target. I'll do self dot camera target. What's going to be more specific. And then let's create remote transform 2D dotnet new, just creating a new copy of that note and add it as a child to the player instance. So player instance dot add child camera target. The reason we do this is so that the camera target will move around with the player. Because children of a 2D node that are also 2D nodes are going to basically have the same position as the parent offset by their own position. So we add that as a child. And then we need to assign the remote path of the remote transform to the level camera, which will make the camera and look at the remote transform 2D. So camera target dot remote path equals level camera dot get path. So the level camera.capture path is just how we find the location in our scene in terms of the hierarchy. To get where this camera target should be telling to look at as things are right now. There's nothing telling our game manager to run this load level script. And also the level kinda just loads on its own. So if we load the level here, we don't have a spawn location set. So what we kinda need is a starting script for the game where when it loads, we should give it specific instructions on what to do. And if you actually had built out like a main menu and everything, this would probably be menu screen and then the new button might tell you game manager, okay, now you need to load the level, level 1 and then add the level was a packed scene and the span location. We don't need that yet. So what I'm actually going to create is just kind of a main.js d. So this will be the scene that loads when we launch our game. So in our resources folder, I'm just going to right-click here and add a new scene. And I'm just going to call it name, so main.js d. And then this will be other node. Let's just call it a base node, not an OTD, not a canvas node or anything. And now I'm going to rename this to be made. And I'm going to attach a script to it. So this would be main.js D. Okay? And this is going to be pretty straightforward. We're going to need to set which scene we should load when we actually start our game. So export. Packed same if our start seeing. And then we need the start location. So export, string var, start location equals layers start. So when this scene is ready, we can just load our level. So function and the square root reading, Game Manager dot load level, start seeing and start location. So you'll recall that this default of players start if we go to level village, we have the players start to spawn location here. And so this needs to match that in order for it to work properly and not throw any errors. Okay, so now with this main.js, we can set that as the scene to launch when we are launching our projects. So I'm gonna go to a project Project Settings and go to General run and change the main scene from level village up a level to main.out TSC and okay, so if we go to 2D view, you can clearly see here that we do not have a player game object in our levels in. Okay, so for this to work, we have to set our start screen. So I'm going to take the levo village and make this the starting scene for our game. And now we can go back to 2D view, look at our level village and just see that there's nothing really here that would indicate that there's a player anywhere on our map. You can't see player and our GameObjects. But if we go ahead and hit play now, it should launch that scene with the player. So you can see the player clearly doesn't exist right there, but that is where our player spot so we can move around and we can see the follow camera still works since we assigned to that after creating the instance of our player. And now if we want to change where the player spawns two, we can just hold Alt down while we click on our players start and just move that somewhere on our screen like down here. Okay, so now after moving our player spawn location, you can see it's been sober here. And there's an issue from the last video which is that not all of the objects have the right Z and X. You can see that the bridge, our player walks under the bridge, not on top of it, but on the same layer. We have these trees over here which are showing correctly. So we're going to have to kinda break our tile maps into a few separate layers for that. So back in tiled for the map village, you can see if I enable and hide the object tiles map that the trees and the bridges are on the same layer. So we need to basically move the bridges to their own layer. So let's create a new layer here. I'm going to call it tiled layer. And, and maybe it could just call it below objects. Okay? And I'll position this below in the hierarchy. And then over here on the custom properties, I'm going to add Z index, just like all the other layers. So this one has a z-index of three, will make this one negative three, so that it shows below the player. And now anything we need to make sure is below the play. When the player walks there, we just need to move that to the below objects layer. So let's use the Rectangle Select. I'll grab these tiles, going to hold Shift down and grab these cells and these tiles Control X to cut them away. Note that it's only affecting the current layer. That's why it didn't grab all of the tiles. Now let's go to the blue objects and paste them in. And you gotta make sure it's in the same spot here. So let's be careful. There should be right there. Okay. So stamped those N. Let's go to File and make sure you export it. So a back-end codon, and we have the new copy of map village. Let's reload that. And let's play the main scene, which is going to load our player in as we load the new level. So our player walks above the bridge. And if we go over here, our players should still be under the tree when we walk behind it. That's how we can basically solve our sorting problem for objects that aren't going to be in this game objects list because this y sort node is only going to sort the objects that are actually in this list. But as you can see, the levels that we're exporting from tiled there, its own separate node, it's its own separate category. So that's why we need the z and x to help us there. So that should basically be just about it for this video and spawning our player into the correct spawn location. And the next one we can work for a transitions between our different levels. 13. 13 Switching Between Levels: So in the last video, we set up the code for a main scene to be able to load up a level and then spawned the player into it where it needs to be. And then of course, our player has the remote transform attached to it after the game loads and after the player has been created. So although that works initially, I do want to correct one thing. So if we jump into the singletons and the game manager script, you'll see that I had it setup using packed scenes. So you can use this to change this into a pact sing. But if we get in the habit of basically telling each object inside of our scene to store a pact seen as a variable. Then you're going to get scenes nested into scenes and scenes. And then if we have, let's say the village referencing the house one and house one referencing the packed scene of the village, we end up with cyclical references and it kind of breaks the game. A better way of doing this, as I found, may actually be to reference the file as a file path and then use that path to use change scene rather than storing the packed scene inside of our levels. So what we're going to take from the load level is going to be a string path. So I'm going to call this level path and stuff. And instead of change s2, which takes a packed scene, we'll use change scene level path. So because of that, we're going to need to also go into main.js. And you can see here we had a start seeing referenced here and another probably works okay for the main scene. Since nothing else is going to be making a pact seen with the main scene in it. So it wouldn't cyclically reference, but consistent with everything else, what we'll do is we use string. But after the string for the export bar, I'm going to put file. So this gives us a special type of string variable and the inspector. So now if we go to main scene and I click on Main, you'll notice this, start seeing other. We can type a path here. We can also use the File Finder. So we want to go into levels and then choose level village dot TSC. And so this just makes it much easier and less error prone to make a mistake with selecting the start level for the game. So now we'll be passing this into LoadLevel as a string to where that scene is located. And then our game manager will be loading the scene based on a string path and the file system rather than the practicing directly. So this is going to help us when we are working on our area. Two d's. So and our love of village, that's going to be the entrance house 001 entrance. How CO2. We can modify that script now, so I'm going to click on the script. So the base script that these areas are being created from is the area move level. So we haven't done anything with it. But what it's supposed to do is with that when the player moves into the area, if we detect that it is a player and send it to another level. Okay, so in order to do that, I'm going to jump into the base seen here. So that was the trigger move level. We created it before. And from here, I want to go to node on the top right, and then use one of these signal callbacks. So what we want to use here is body entered. Our players are kinematic body 2D, which is a type of physics body. So it qualifies for this. And I don't anticipate changing that base node for this game. So we're going to use body entered. So when we double-click this and add a receiver method on trigger move level, body entered. So it means when the body entered, we can check if it's a player and if so then we can switch levels. So I'm going to connect that to the script itself up here on the area 2D. So the first thing we need to check is if the body is a player. So if body is player, now, that's not going to work right now because we haven't declared player as a type. So I'm going to go into player, the script, and up here at the top, I'm going to write className player. So now we can check if the physics body that gets recognized here is of class type player. And if so, then we can just tell the game manager to switch level. So game manager dot load level. And now we need the export far as to say for this area to D where it should be going and where the spawn point is on the level for this transition. So export, and it's going to be just like the main.js. So string file, because we're doing a path to a level and then export string. It's been location. And this will be destination level. And we can actually call this one destination spawn. So Destination, destination spawn, those get passed in as variables here. So the game manager will load the level and then it was spawned the player at destination spawn. So because we're going to have a lot of these area to these for transitioning levels in the game. And we might delete one of the levels from the game entirely. And we want to know if that level currently exists or not. I have some code we can use to check if the destination levels valid and then if a destination spawn is set. So the destination spawn will just see if it's not null or not. A empty string. I'm going to paste the code and then we can talk about it. So here's some tests we can run while we are editing our game and just make sure that everything is setup correctly before it becomes a real problem. If the destination novels know are set to nothing, we can have a error message print out to the council that there is no destination novel set. Else, we can check using a new directory object. And the directory class has the method here file exists. So we check the destination level path and see if it actually exists in the file system. So if it doesn't exist, then we're going to say it doesn't exist at that location, turning the path enter a string. And if nothing is set, then we'll say it has no destination level. So that can give us a clue that it hasn't been settled, right. And that trigger isn't going to work if we actually try to walk over it. Also for the spawn would just see if something has been set there. So we're referencing the name of a position 2D that exists in another scene. So this will just make sure that we actually set it when we actually create these triggers. And this doesn't guarantee that this exact spawn exists in the other scene, but this is something we can use to catch some basic problems. So I recommend having this code here. So you can just kinda copy that off the screen if you want it. And aside from that, we just need to set a destination of on a destination spawn for every trigger move level we create. And then when the player walks in, it's going to switch levels, which is what we're looking for. So now and novel village, we can click on our entrance house several one and go to the Inspector. And we can see the variables here to set. So destination level, we're going to set as 0, 1, the scene and destinations bond. We can jump into that level and just take a look at the name of some of the spawn locations. So we have front entrance and stairs down. We're entering the house, so we want the front entrance. So I'm just going to double-click here, copy the string, go back to level village, and let's paste that in for the destination spawn. So that's all we needed to there. Now let's make sure that we can actually go back out of the house. So on level village house 0, 1, we're going to take the front door, an exit here, and I'm going to set the destination level, levels, level village. Okay, and now destination spawn. And let's go ahead and set that to the player start. So I'm going to copy that spawn point name. Let's go over here and paste that into destination spot. So now let's go ahead and run our tests. I'm going to hit play. And okay, we still got the players spawning down there at the middle of the map. That's not too helpful, but let's see if we can enter the house. So we go up here and level camera. So that level has not set up the nodes yet. So let's close that. And now we can jump into level village house. So rule one, click up here and we've got to assign the level camera, the game objects that transitions in the spawn points. So I didn't mention in the last video of these aren't set. It's going to give you an error, which is good because it's like an early warning that we haven't set up the level properly. So level camera, Let's assign the camera. Actually is no camera yet, so I'm going to add a camera, right-click, Add child note. So camera 2D. And what you could do is have kind of like a template level where you just have these by default. And then you can create instances of those from your template. So every level is going to need a transition list as spawn points less than a camera 2D. I'm not gonna do that right now because we just want to test the level transition codes. So I'm going to right-click on the base here and we need to add an a why sort or the game objects. So I'm going to rename this game objects and position it up here. I'm going to click on village house 001. And we want to assign the camera. And we want to assign game objects that list so that the character can be added there, the transitions and the spawn points. So now for the camera TD, we should set limits to. So let's open up the editor, draw limits, and then let's go to the limits and I'm going to set this to 0, left, 0 top. Okay, and let's do right of 300, bottom of 300. And just adjust this a little bit more until we actually get it to kinda surround the house. So just need the yellow box to not go too far to the left, and then this should be a 100. So these are roughly the limits that came up with for this camera. And we need to make it current. So I'm going to set that current up there. So as you can see, the camera is actually bigger than the level right now. So maybe the camera is currently showing too much and we need to shrink the window size in the project settings. I'm just going to leave that alone for now. So anyway, we have limits, we have a camera and everything is setup. So let's just change one more thing on level village. Let's take that player spawn point and let's move this closer to the actual house for convenience. Okay, now we can go ahead and hit play and see if everything's working yet. So we're going to enter the house. Okay, I'll play respond to there. And we can walk around the house. Collisions are still there. And we can hopefully walk out of the house. Okay. And you'll notice that the play when we exited, we spawned him again, right at that player spawn point. Of course, we'd probably want to have a exit point right around here. So that makes it a little bit more sense than spawning him here. But this is just testing purposes so we can go into them out of the house. And that's the basics of doing level transitions for your characters. So that's pretty much going to wrap up this segment on creating and working with the levels inside. Oh, one last thing I do want to point out, as I mentioned, those error messages down here. Since we have all of these printing text we can easily catch if we forgot to set a destination novel or a spawn for any of these extra area transitions. And you can imagine if we fully built out this village with 10 or 20 exits and entrances, that there could be a lot to check here. So I think that will be helpful. So that's pretty much going to be it for now. Thanks for watching. I've been Chris, and hopefully I'll see all of you in some of my future ghetto content.