ATTBT Basics #2 Tiles

September 28, 2024

hello in this video I'm gonna be talking about various ways of setting up your grid and customizing the grid so let's first get a grid manager down so we're here in core grid VP grid manager I'm gonna place this at 0 and I'm gonna increase size 12 or something like that why not and and let's place a unit so that we can walk around on the grid I'm gonna use BB unit Adam and here we are okay so let's start by talking about tiles so tiles as I said in the last video you can find them in the tiles folder and in square you have some tiles set up to work with a square grid also as shown before placing a tile on the map will block pathfinding like so but how does this how is this set up exactly let me demonstrate with a few different kinds of tiles so we have this tile here which is called tile wall block and we have this which is just called wall and we have another one here which is called tile wall II for east and so if your different ones and you can see that they behave differently that were able to walk behind this thin wall here but that we have to move around it and for this one we see that we can move around it and for this one here it's similar it just that we can also cut through corners of this tile so how does this work well each tile hair on this grid are connected to its neighboring tiles through what are called edges I won't go into that in detail in this video I'll dive in depth in that in another video but what these tiles essentially do is that they look at these edges that each of these tiles have and it removes some edges based on the values that are defined within the edge cost variable of each tile which you can see is a bit different for each of these three tiles you can see the these edge costs they are named after the cardinal directions north east south west north east and cetera so these are referring to the axis on the grid manager so if you click the grid manager then in the x-axis that will be East and the y-axis will be south so if you look at the grid manager from this rotation then these naming conventions make sense so for this tile here we can see that it has an edge cost of zero in every direction what this means is at the star of the game this tile looks at the tile that it's placed on which is the tile here and below it and then it looks at each direction and it changes the edge cost that was there before with an edge cost of zero removing that edge from the grid actually that's not entirely precise it doesn't create an edge of zero it just removes that edge but what this means is that when pathfinding tries to enter this tile it finds that the edge costs here the edge does not exist so it cannot enter and the same if the unit starts within this tile and we start playing you can see that we can't move anywhere because all of the directions are blocked for the path finding of this unit we can also add tiles that have costs that are greater than one so if we add this to tile cost tile here it is set up like that by default so we can see here that it has a cost of two to enter this tile so if we hit play we see that the unit will want to avoid going into this tile but we can still move through it the amount of movement the unit has is defined within the unit by the way we then move here but I'll get more into how to customize units in the later tutorial so back to this tile so it has a cost of two if we just put all this back to one we can see that it treats it as regular tile we can make it greater or back to the same job it acts as a higher cost again there's one more setting remaining to discuss and that is if we choose one of these actors you can see here that they have edge costs of minus one what does that mean exactly well this is what is causing this tile here to block these corners so that you can't move around it or that you have to take a long route and can't cut through corners as you can with this tile here and so minus one is basically a special command that tells the toolkit at setup to look at the tile edges crossing the sides of this tile which are outside where the tile is actually placed at and then blocking off or changing the movement cost of those tiles if you want to create your own tile that's a pretty simple process and I can click here and then create a new blueprint after right-clicking I search for tile and here it is BBD a tile I will call this vpg a tile custom and by default it is immiscible we have no mesh but it can still affect pathfinding in the same way as any other tile as you will see so if I set this hair and I have increase the cost for all of these edges we can see that he avoids this it's like with this other tile here having invisible walls can be useful of course but we probably want to visualize this in some way so we go into this tile actor here and we can add a static mesh and we can choose from one of the static meshes that are included in the toolkit let's find one table like this crate hair which is works well for a and for a tile and now you will see that there will be one issue here that it does not snap to the grid currently but it will still lock the tile which it is placed on or change the edge cost of that so let's change the edge costs here to zero and we will see that it locks this and we can move around it and behind it but it is not centered on the tile so the way to make it Center on the tile and snap to the grid is to go into this and then attach it to the grid anchor which is a scene component that is used for the grid snapping functionality the grid snapping functionality is defined in the parent actor here so now we can see that it automatically snaps to the grid we can also make the location of this actor and the location of this mesh to be aligned by clicking this place accurate anchor button hearing we click away and click back we can see that they are centered we probably don't want to define the edges of a tile every time we place it of course you can change this in the defaults here of these tiles let's go to edge cost here and I'm gonna put all of them to zero maybe I want to block the corners here so I'll put all of these two minus one there and now we can place more of these and they will work just like that so that's it for tiles so tiles are nice and all and they were the first method of manipulating and grid edges that I added to this toolkit over five years ago but I've since added other methods also that are very useful it is possible to have the grid manager calculate edges based on the collision properties of meshes placed in the grid area and that is what I'm going to show in the next video but that's it for this video on tiles


Profile picture

Written by Urakaiketsuya , just a guy who codes. You should follow them on Twitter