How to generate Navmesh at Runtime Unity? (Dynamic Navmesh)

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
in this video we will learn how we can generate NAB mesh at run time hey guys it's me auro so without any further Ado let's jump right into the video in unity I already have a scene setup for you which pawns cubes in the spawn points so if I just hit play as you can see some Cubs are spawned and let's just open the navigation window to make sure that I don't have any nav mesh bake in my scene so how do we fix this problem how do we bake a nav mesh at run time first let's take a look at our scripts we have a pretty simple spawn obstacle scripts and the nav mesh script is from our previous nav mesh video so how can we generate the nav mesh at run time so in order to generate the nav mesh at run time we can do that with the version of navmesh that comes shipped with unity as you can see in the navigation window in the bottom you can see that to try an experimental component based workflow for configuring nav meses install the AI navigation package so that means in order to generate the nap mesh at run time we'll need to work with an experimental package so how do we install that experimental nav mesh package so I'm just going to go to our window package manager then I'm going to click on this plus icon here and I'm going to select add package by name I I'll link this documentation in the description below but from this documentation or from here what I actually need is this line of text which says kong. unity. a. navigation I'm just going to copy this and paste it in here and click on ADD as you can see it will start importing the AI navigation experimental package into my projects I'm going to wait sometimes for it to install it in my project and then if you want you can import the samples but I really don't need the samples so I'm not going to import them and then what we can do is go to our ground and then add a component called nav Mish surface then we can reference this n surface and do a lot of things in our projects so let's open our spawn obstacle objects and let's first reference our nav mesh surface so let's type public and nav mesh but as you can see there's no suggestion of our nav mesh surface and that's because we need to import a library up top here called using unity. a. navigation because the nav surface is in the unity. a. navigation name space so we need to include that and then we can type public nav Mish surface as you can see now it shows here and I'm just going to go nav mesh and after we spawn our Cube I'm just going to call Nav mesh. build nav mesh open and close parenthesis and that's it really that easy so I will save the script now and go back to Unity and make sure to reference our nav mesh surface so I'm just going to click on spawn points and in the nav mes section I'm just going to click drag and drop the ground which contains our nav mesh surface so if I now hit play and move back to the scene View and the navigation window as you can see it currectly builds our nav mesh with the obstacles included and as you can see the nav mesh is C correctly working the agent is actually working on the nav mesh and it's avoiding obstacles and everything so that's pretty nice if I now if I just move the spawn points to something different and play the game as you can see it also currectly builds NAB mesh so it's actually building the NAB mesh after everything is spawned in our level so there you go guys that's how you bake a nav mesh at runtime if you don't know the basics of nav mesh I already have a video on that so go and watch this video to learn the basics of nav mesh until then I'll see you in the next video goodbye
Info
Channel: Ghost Studios
Views: 236
Rating: undefined out of 5
Keywords: ghost studios, ghost game development studios, ghost games studios, unity, unity3d, unity game development, programming, programing, 3d, 3d artist, game development, game dev, game developer, navmeshagent unity, navmesh unity, navmesh pathfinding, pathfinding in unity, navmesh areas, navigation in unity, unity pathfinding navigation, navmesh baking, how to bake navemesh surface unity', navmesh surface, dynamic navmesh unity, navmesh at runtime, generate navmesh runtime unity
Id: 6wfsDdgjEKo
Channel Id: undefined
Length: 4min 25sec (265 seconds)
Published: Fri Apr 05 2024
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.