ATTBT Basics #3 Walls

September 28, 2024

welcome back so now we're gonna look at how we can get the grid to generate edges and do the hard work for us so let's so these are all the tiles from the previous video and just get those deleted and then let's add just a regular cube so first let's add a cube and to the grid like this and I'll resize it a bit now this cube if we press play doesn't do anything you can see you can pass right through it because the grid has no way of knowing that it exists so we need to tell the grid to look for things like this cube that is simple enough to do if we select the grid manager and we scroll down to the config options here we will find this boolean here which you can check for trays for walls so if we check this we will see that we can now no longer move through this cube even though it's just a regular mesh with no special code attached to it we can see that you can also create you know thin walls or whatever shapes you want using this method it's great a thin wall like this and it will have the same sort of thing that you can now move around it and it blocks walkability so how does this work well it works by the grid manager at startup using a line trace tracing in every direction to the surrounding tiles and if that line trace is blocked then that edge will be removed we can see this if we go into the grid manager we edit the blueprint here now here is the activate grid manager event which is called from the game state at the beginning of the game and lots of stuff happens here which is covered in other videos let's set up no I mean set up grid arrays it's what we are interested in and here we have the generate grid edges event and here you have the one that adds the edges of the tiles and tile actor placed in the viewport to the grid by the way but this is the one that we are interested in now set edges based on terrain we have three different calls here based on and if we have a multi-level or one level grid or if we don't have any height differences though more about these two at a later point but first height map is set to false on our grid and so we add tile edges no height map and here is the trace so we can draw a debug persistent line trace for this so that I can visualize for you guys how this works so if we now hit play you will see that line traces go in every direction from each of these tiles and these places here you can see that these traces are blocked so you can see that the trace from this tile the center of this tile that the center of this tile is blocked by this mesh and thus this edge between these two and the edge going the other way are both removed we can see that if we resize this mesh slightly we can now move past it because these corner edges are no longer blocked by this line trace also note that we use a custom collision channel for this so if we go to one of our measures and we find its collision settings and and we can change this to custom and then it will find the wall trace channel here and if we ignore this channel for this mesh then we will see when starting the game that we can again move through and ignore this mesh entirely and so this means that anything that you place in the area of the grid that blocks the all tres collision channel if you have tres four walls enabled here tres four walls enabled and the World Trade Center you can also set up here if you want to use a different channel but if this is enabled whatever stuff you've placed on the grid which blocks this channel here will then remove edges between the tiles and where it is placed you may notice that there are a couple of different trace channels defined within the grid manager we have the path traced channel and the arranged trace Channel and now the path trace that is used to define what parts of the grid can be walked on so anything needs to block path traced if units are should be able to walk on top of it well Range trace that is used during gameplay to determine a visibility for these units so if they can target other units with attacks or if they are blocked by meshes etc I can show this briefly with the unit here if we go back to this mesh we edit it and in the collision settings we can see that it blocks range trace and path trace which means that this mesh will be considered when generating walkability on the grid which tiles can be walked on since height maps are not enabled right now and all the tiles will be at the heart location zero but more on that later but for range trace this means that this mesh should block visibility now if we go here yeah first let's go to the grid manager and turn off this debug.trace so that doesn't bother us now if we select this unit and we increase its range to something higher like 12 and hit play we can see that it doesn't work right outside oh yeah it's too low so the height at which you can see tiles is defined within the abilities that you are using but yeah so we need to make this taller and if we now hit play we should be able to see that yeah we are blocking line-of-sight and that is based on where we are standing so lastly let's talk briefly about the path traced channel so that's the collision channel that defines what parts or what inside this grid can be moved on top of so by default the grid manager it blocks path trace for the entire grid and it doesn't do this with each of these individual tiles having collision enabled but instead it has one large plane that covers the entire grid manager no matter how large the grid manager is and so we can show this collision plane here but we can also then set this disable collision plane walkable now this will work a bit strangely now that height Maps is set to false but I will show this so we can see now that there let me turn off the collision plane visualization here so that's a bit more clear to see so we can see that we can still move to all of these places but we're not able to click here and that's because of these abilities they try to see if the collision trace channel or the path trace channel is blocked beneath the mouse so you can see that if we hover over these meshes that then the ability is able to find the tiles here but since this collision plane no longer blocks path trace our mouse is no longer able to find the grid but still all of these tiles are considered being part of the grid and thus path finding can be done of them on them this is when height map is been set to false which means that it's the grid manager considered the entire considers the entire grid to be walkable by default and it doesn't bother doing traces to type try to check if there are any tiles missing or something like that so if you want the grid manager to check if there are tiles missing we can set height mapped to one level and now if we click play we see that we can't move anywhere but we can then add another cube here which by default blocks path trace we can resize it and we can move this unit here so it's on top of it and now we can see that we're able to move on top of this mesh because it blocks path trace but yeah and this is bit of what is in the procedural height map features of this toolkit and that's what I will be talking about in the next video


Profile picture

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