Easy Pathfinding with Unity AI Navigation

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey there it's me hammad and today in this video I'm going to show you how pathf finding Works in unity using AI navigation so without wasting any more time let's get started so this is my simple 3D scene with a player ground obstacles walls and a sphere now the first step you need to do is to install AI navigation for AI click on the window then package manager and click on packages now here select Unity registry and search for AI navigation once you find it click on install and wait for a few seconds after installation close the window now here we will bake our plane so our player knows where he can walk and where not so click on Windows and here you will find AI over on it and once you click on navigation obsolete this navigation window will appear now you can place it with the inspector window or anywhere you want but I will place it with the inspector window now click on the plane and in the inspector window check this static box now come to the navigation window select bake and click on bake now you can notice that the color of our plane is changed I also want my player to recognize the obstacles as well so select the obstacles come to the inspector window check the static box and press yes to change the children if you have any again come to navigation now here if you want your player to jump or fall from height you can change these values for me I will keep it four and then press bake after baking you will see the these types of circles and lines now come to the project window and here we will create a script for our player I will change its name to NV mesh and open the script now first of all remove the start function because we don't need it and here we will use an assembly with the name AI so we will write using Unity engine. a after that we will create two variables the first is public transform called Target Direction and the second is private NV Mish agent Called Agent keep in mind that the target Direction and agent are variables and you can change their names now we will create an awake function so as we write awake and press enter or function will be created automatically here we will write agent equal to get component n mesh agent with the help of this line we get the n m agent component we will also create this component in the editor in the update function we will write agent. destination equal to Target direction. position with the help of this line we can move our player toward the specified Target destination now press controller command s to save the code and let's go back to the unity here select the player and drop our Nev mesh script click on the component and search for Nev mesh agent also drag and drop or destination point which is a sphere into the target destination and now let's test it so you can see that our player is following the destination point and if we move it our player will also follow it let's place our point point on the bridge you can see that our player is still following the target point and our player also jumps and falls on the ground in this way you can move your player using AI navigation and nves so that's it for today if you haven't already make sure to like the video and subscribe to my channel it's totally free and I'll see you in the next video
Info
Channel: HEXGAM
Views: 133
Rating: undefined out of 5
Keywords: hexgam, unity game development, game development, how pathfinding works in unity, pathfinding in unity, ai navigation in unity, How to use Ai in unity, easy game dev tutorials, unity, unreal engine, blender, photoshop, game designing, how to learn game devlopment, unity game development tutorials, pathfinfing, navmeshagent in unity, Pathfinidng and NavMeshAgent
Id: iYcI_15M3R0
Channel Id: undefined
Length: 3min 31sec (211 seconds)
Published: Thu Mar 14 2024
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.