How Nav Mesh Links Work | Unity AI Pathfinding (Part 5) | Table Flip Games

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] hi I'm Tommy Thompson and this is part five of the pathfinding in unity tutorial series here on tableflip games in parts three and four of the series I looked at setting up a simple non player character or NPC the patrol the set of waypoints courtesy of a navigation mesh built within a scene these were pretty straightforward bordering on crude implementations but enough for you to get something up and running now each of these examples relying on a very specific constraint I set up in this series from the beginning byte navigation mesh is being baked onto one large plane and I'm carving chunks out of the plane using the nav mesh obstacle components now the thing is that's not how environments are builds game worlds are not one massive chunk of terrain there are large numbers of individual pieces of terrain that are snapped together to give the illusion it's one area so with that in mind how does a navigation mesh work across these small individual pieces we can build an erv mesh on each of these individual pieces of geometry but what about been able to navigate across multiple pieces of geometry to get to a destination even more interesting what happens when they start to leave gaps between the meshes can an agent navigate across those gaps in the space in this tutorial I'm going to show you how unity enables these features including an example of a special component used within the nav mesh system known as off mesh links first of all how do we deal with multiple pieces of geometry well the good part is that unity largely deals with that for you but they did you run the bake settings correctly so in this example I have on screen now have a plane set up in the world in addition I've used the simple NPC that I built previously as well as the simple destination location if you're not sure how these work jump back to part one when I make each of these from scratch now set the destination for the non player character to be this destination object er in addition of also baked in the navigation mesh on the floor game object so nothing we haven't seen before this is all quite straightforward except that the destination location is not on the navigation mesh it's actually over the edge and sort of hanging in space here so what happens when I let this run the NPC walks to the edge of the navigation mesh set up on the floor plane but it won't go any further than that it's also smart enough to not walk over the edge and fall to its doom but ultimately it's still trying to get to location it can reach so how about if we just add another piece of geometry that fits something nicely to it so first of all let's start by actually just duplicating this floor piece here that I've got I call it lower two and I'm gonna move it somewhere in the scene that's a bit over here now if you want to snap another piece of geometry to it such that it's flush you can either sit here in the inspector and start tweaking the sentence accordingly you know is it four or five or five point when it's actually only gonna be five units I've prepared this example so that this one has to be a five and this one has to be at minus five and those set flush but you can't always guarantee on another way to get around this is if you hold down the V key on the keyboard you can then actually grab an edge of a game object and then I'm going to grab it and I'm gonna snap it to it here and you can see that it actually says Quay flush now if we run again try it out it still doesn't work why is that well if we go into the navigation pane you can see that I've only still beat the navigation mesh for one side of this kind of to plain piece of geometry the navigation mesh has to be baked for the second part now when I go back I can embed that second one let's just go in and bake it you'll notice that the two navmesh is linked together the navmesh system is pretty clever and figures out that these two planes are next to each other with navigation mesh is being baked on them so it ensures that the two linked together meaning that this time when I play the MPC now successfully walks from one plane to another without any problems now I built these two separately but I can do it all in one batch so if I actually cleared it I could select each of these items I want make sure that these are both being selected here and then bake it and it'll work out just fine alternatively you can make your floor plains child objects of another game object and then simply bake the parent and in this case it will then bake everything together so these two were both baked because that they are child objects of this parent object now there are still points when this does not work namely when I have a setup like this here you can see I have two surfaces but they're ever so slightly apart in addition when I beat the navmesh as you can clearly see that these are no two separate meshes and they won't connect with each other anymore so even though there is a navigation mesh here if I try and move across it it's not going to be able to move across to that other one how can we then resolve that well to do that we can then use what we call off mesh links off mesh links are special link ups that allow for an agent to cross from one navigation mesh to another this is ideal if you want to have an agent that can see jump between navigable areas or can fall down from higher to lower points in a world though there are multiple ways in which you can place off mesh links into a world as well as a variety of configurations given you may not one a non-player character to be able to claim back up from a drop that they've previously used in addition we can't have them placed manually or automatically in this tutorial I'm going to focus just on the automatic construction that can be done by the nav mesh generation so to resolve this example I've got here I can tell the navigation mesh to create off mesh links between the two planes automatically but these are limited but the drop height between the two locations or in the context of this example the jump distance in the beak tab of the navigation pane we can change these two variables as you can see here in the generated of mesh links options I'm going to change it so the jump distance is around 10 which i think is a bit overkill for this example but it should actually work out okay and then into the object tab I have to tell it to make sure to generate the off mesh links now when I bake it you can then see these items here that appear these are the off mesh links that's now showing if we are at one of these locations here we can then jump across to this other one when we press play you'll know that the character now could have jumps across but the behavior looking a little different as they move from one nav mesh to the other note that the character doesn't jump realistically rather they simply move from one link to another this is pretty much expected given its providing as the functionality but not the visual behavior and you'll see the same thing in this example here where I've actually made the gap between them even bigger this time when it goes to jump across it's still the same thing it's just a bigger gap that is navigating that cross but we're still getting that kind of sliding behavior between the two navigation meshes I think I say this is pretty much expected it's just providing as functionality not the visual part of the behavior if you really wanted to get that sort of behavior where you saw it actually jumping from one site to another you would typically require an animation system to give you that visual behavior you wanted in this instance you could actually configure it so that when you hit the off mesh link you trigger the animation that gets it to look like it's jumping from one place to another so with this tutorial complete we now have means to generate larger nav meshes across multiple surfaces and even linked distinct nav meshes together after slightly apart from one another this allows us to build more interesting navigation spaces for both players and number characters in future tutorials I'm going to continue this process and show more features of off mesh links and how we can utilize them to create unidirectional paths or you know paths to only go in one direction I hope you placed them manually how to create vertical gaps and a bun of other small tweaks that you can make to get the most out your NPCs this has been part 5 of the unity pathfinding tutorial series here on tableflip games don't forget to Like and subscribe for more game dev tutorials plus our channel is supported over on patreon so if you'd like to get access to our videos early full on new topics and get access to original source materials head on over to patreon calm Paul sighs tableflip games thanks for watching [Music] you
Info
Channel: Table Flip Games
Views: 18,406
Rating: undefined out of 5
Keywords: table flip games, tutorial, gamedev, navigation mesh, AI nav mesh, ue4 navigation mesh, ue4 navmesh, alien isolation ai, AI 101, unity nav mesh, nav mesh, terrorist hunt, artificial intelligence, ai and games
Id: WBXti5pea88
Channel Id: undefined
Length: 9min 15sec (555 seconds)
Published: Thu Jul 04 2019
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.