How to use Unity NavMesh Pathfinding! (Unity Tutorial)

Поділитися
Вставка
  • Опубліковано 21 лис 2024

КОМЕНТАРІ • 294

  • @CodeMonkeyUnity
    @CodeMonkeyUnity  3 роки тому +11

    ✅ Get the FULL course here at 80% OFF!! 🌍 unitycodemonkey.com/courseultimateoverview.php
    👍 Learn how to make BETTER games FASTER by using all the Unity Tools and Features at your disposal!

    • @NoldoWalker
      @NoldoWalker 3 роки тому

      is there some lessons about mixing navmesh for npc and a way to use it to forbid controlable Player character to go somwhere?

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  3 роки тому +3

      @@NoldoWalker I cover area types in the end of the video, you can use that to disable the player from going somewhere if you're using NavMesh to move the player.
      Each agent has their mask for areas they can traverse, you can make that different for the Player or NPCs

    • @NoldoWalker
      @NoldoWalker 3 роки тому

      ​@@CodeMonkeyUnity i mean how to prevent some character to move if it controled by player. Other words : is navmesh working same way if you control actor by keys trough AddForce / aplying new transform.position value

  • @DannyHodge95
    @DannyHodge95 3 роки тому +15

    Jesus, this used to be a complete pain to get working, and now it's like 2 steps, the Unity team have smashed this! Thanks for the tutorial

  • @seb.5053
    @seb.5053 3 роки тому +5

    I legit saw you today in the supermarket, recognized you by your voice.

  • @ChrisVideosGreek
    @ChrisVideosGreek 3 роки тому +46

    Never stop these videos. l'm a beginner. Totally the best way to learn some things even if without the course (even if l think it's cool)!

  • @astroboystan
    @astroboystan Рік тому

    OH my gods thank you!! The old tuts i watched told me to pull up NavMeshSurfaceComponenet which I'm not sure exists anymore and I was about to have a breakdown because I didn't know how else to get the level working. THANK YOU!

  • @EskChan19
    @EskChan19 3 роки тому +139

    One thing that i'd like to add is that there's a Component called NavMeshObstacle that has a few settings and can be made an obstacle at runtime without needing to be baked. That's very usefull if you make a game where the walkable area can lessen mid-game, for example a Strategy Game where you build buildings. Adding the Component to the buildings Prefab will make it so that the buildings will no longer be considered walkable for Agents, even if there is a pre-baked navmesh there

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  3 роки тому +20

      Yup, I plan to cover that and more advanced use cases in another video when I make the first course update.

    • @TheKr0ckeR
      @TheKr0ckeR 2 роки тому +2

      @@CodeMonkeyUnity waiting

  • @alextrollip7707
    @alextrollip7707 3 роки тому +10

    Crazy.
    I literally just spent today on this.
    Doing the surfaces and mesh modifiers was interesting.

  • @seba0456
    @seba0456 3 роки тому +1

    I love UA-cam for showing UE4 user unity tutorials 😀

  • @kotzikuche7883
    @kotzikuche7883 3 роки тому +8

    Insane, I was literally trying to figure out how the navmesh works and this video showed up! Thanks mate you helped me out a lot 👍

  • @daffertube
    @daffertube 2 роки тому +28

    Friendly reminder to enable Gizmos in your scene viewfinder. Otherwise you won't see the blue navmesh.

  • @slimxshady6111
    @slimxshady6111 2 роки тому +6

    First video i've seen of yours and won't be my last! Thank you very much for going through this, especially the second half where you explained every option in NavMesh. I feel a lot of tutorials show you but don't care about understanding, which leaves you dry the moment you try to change something for your own game. But now I properly understand how NavMesh works, and have utilized it great in my game! Have a great day!

  • @AtariKafa
    @AtariKafa 3 роки тому +14

    Ultimate Unity Overview awesome keep updating thank you :)

  • @castlecodersltd
    @castlecodersltd 2 роки тому +1

    A good explanation. Thanks

  • @TheAntox007
    @TheAntox007 Рік тому

    Thank you for an explanation, finally figured out the damned stairs and the jump, thanks!

  • @sultanrahil3380
    @sultanrahil3380 2 роки тому +1

    Amazing lecture. Good job

  • @jesse143_
    @jesse143_ 3 роки тому +1

    WOOHOO NEW CODE MONKEY TUTORIAL THIS IS F-CKING AMAZING

  • @29void71
    @29void71 2 роки тому +1

    Amazing tutorial!

  • @justinwhite2725
    @justinwhite2725 3 роки тому +1

    Ooh thanks for this. Been thinking about navmeshes recently.

  • @Maggiethegsd
    @Maggiethegsd 3 роки тому +2

    I get annoyed by your ads, but goddamn the tutorials are clear and awesome. Brackeys one got a bit outdated so I came here, and found everything that I needed. Thanks!

    • @RealBrianRussell
      @RealBrianRussell 9 місяців тому

      ????? How about all the free content he releases?

    • @twinguy9633
      @twinguy9633 8 місяців тому

      @@RealBrianRussell He advertises it in a boring annoying way, its not about the advertising itself.

  • @wortwortwort117
    @wortwortwort117 Рік тому

    I spent 3 days trying to understand how to move an enemy and was so satisfied, then I see this much MUCH easier method like bruh

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  Рік тому +1

      Whatever you did, I'm sure you learned a lot so it wasn't wasted time! Keep on learning more and more things!

  • @a.technology1446
    @a.technology1446 3 роки тому

    We can't imagine unity tutorials without u ❤️🙌

  • @kozmobotgames
    @kozmobotgames Рік тому +3

    This Navigation window is labeled as Obsolete in Unity 2022. How can I do NavMesh in the latest version of Unity?

  • @webplace8268
    @webplace8268 2 роки тому +1

    Great tutorial. Im working on a horror game and im shitting myself bc there a capsule following me and I love how easy it was

  • @ElSonk
    @ElSonk 3 роки тому +1

    Ah finally, a new Codemonkey tutorial!!

  • @qasimahamad5075
    @qasimahamad5075 2 роки тому

    I'm too glad to watch this video. Thank You.

  • @peche87_gameDev
    @peche87_gameDev 3 роки тому +5

    I would like to see how to manage bunch of entities trying to achieve the same position. Sometimes, there are a kind of clamping between all moving entities or entities that seem bouncing trying to reach their goals and not stop when there are a few of them at the goal position. I think the best way to manage that is with flow fields but I would like to see an approach with only nav agents, nav obstacles and set them dynamically. Great content as usual! :)

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  3 роки тому +1

      Unity's NavMesh already has object avoidance built-in, so with the default settings you won't see them overlap.
      You can see that in action in the RTS game where I used NavMesh ua-cam.com/video/y601TRfoxc4/v-deo.html
      For a massive amount of agents then yeah using flow fields would probably be the better approach.

    • @peche87_gameDev
      @peche87_gameDev 3 роки тому

      @@CodeMonkeyUnity Thank you so much for taking the time to answer it to me. And thank you for all your content as usual. The best content and explanations as usual dude, thanks!

  • @ivanivanov9705
    @ivanivanov9705 Рік тому

    Very, very, VERY nice video. Thank you. Now I know how to use nav mesh agent.

  • @mdk162
    @mdk162 3 роки тому

    it fixed my day. thanks for making this tutorial

  • @brendanleighton
    @brendanleighton 2 роки тому

    Thanks Code Monkey! That NavMesh was driving me bananas!

  • @harrynrtnj
    @harrynrtnj 2 роки тому

    Thank you

  • @geodude1725
    @geodude1725 3 роки тому +2

    This is fantastic - would love to see this with some logic using unityVS with scenarios like the Nav agent picking up then dropping off a box at his destination. Thanks CM!

  • @memepotater9503
    @memepotater9503 3 роки тому

    As it stands, the game I'm making doesn't require this fancy nevmesh. But I do love watching your videos. It's both entertaining and make my mind go wild from thinking of all the crazy ways I could use the different things you introduce to us.
    Love from the 🥔 gang.

  • @aussieraver7182
    @aussieraver7182 2 роки тому +1

    Amazing as always, you've got yourself a subscriber!

  • @zainjavaid7659
    @zainjavaid7659 2 роки тому

    Thank You for awesome explaining!

  • @shiv-iwnl8188
    @shiv-iwnl8188 3 роки тому +2

    Hey can you please do a tutorial on how to use use the LOD component in ecs?

  • @wajeehasamreen5711
    @wajeehasamreen5711 3 роки тому

    plz continue making this types of videos plzzzz.........😊😊😍😍

  • @jud.su.5developer895
    @jud.su.5developer895 Рік тому

    O my god so nice I don’t know that navmesh can jump form cube to another or drop thank you so much ❤

  • @MiniFrenchAdventures
    @MiniFrenchAdventures 2 роки тому

    Perfect explanation. Thank you so much

  • @misal-isahabe5281
    @misal-isahabe5281 7 місяців тому

    Thanks for this contants! See you next time!

  • @MarceloLemosRossi
    @MarceloLemosRossi 3 роки тому

    Nice tutorial. My game is top-down with click to move. I'm going to use NavMesh and you helped a lot.

  • @zitongstudio
    @zitongstudio 2 роки тому

    Thank you! All the essentials I was looking for.

  • @Jay_Bacal
    @Jay_Bacal 3 роки тому +1

    Well done!

  • @A_Kiwi.
    @A_Kiwi. 2 роки тому

    tysm, this is perfect for my rts game!

  • @jean-michel.houbre
    @jean-michel.houbre 3 роки тому

    Very clear, as usual.

  • @ameliapl868
    @ameliapl868 2 роки тому

    Thank you so much!! It worked

  • @nguyenhuuphu8371
    @nguyenhuuphu8371 3 роки тому

    Fascinating video. Thank you so much!

  • @danielvillalba4457
    @danielvillalba4457 3 роки тому

    Pretty nice explanation on the NavMesh system, thanks a lot!

  • @RUDERUDYTUTORIALS
    @RUDERUDYTUTORIALS Рік тому

    This video is really helpfull thank you very much awesome work.

  • @y01cu_yt
    @y01cu_yt Рік тому

    Thanks, it was nice and clear!

  • @ameleustv3093
    @ameleustv3093 3 роки тому

    This is a very nice and detailed video.

  • @marshallross3373
    @marshallross3373 3 роки тому

    Great demo/tutorial. Thanks for posting!

  • @AngeloKim
    @AngeloKim 3 роки тому

    Great tutorial! Will definitely come back to this video when I get to making the enemies in my project.

  • @StygianStyle
    @StygianStyle 3 роки тому +1

    Interesting. the "official" tutorials seem to state that you need the NavMesh surface component, still in preview state, to get this working. Very confusing documentation at Unity that has caused many hours of frustration. This tutorial is great though. Thanks.

  • @dafafdsafdas8770
    @dafafdsafdas8770 Рік тому +1

    very useful,thank you!

  • @eniocc
    @eniocc 3 роки тому

    Very helpfull content. Thanks sir.

  • @alltidtratt3564
    @alltidtratt3564 Рік тому

    Great and clear thank you 😊

  • @christopherfarrell-artist3557
    @christopherfarrell-artist3557 3 роки тому +1

    As always, you are informative and educational. Thank you!

  • @Happyhenzo
    @Happyhenzo 2 роки тому +1

    For some reason it won't let me use the drop height and jump distance no matter what i set the values to

  • @melomaniakjm
    @melomaniakjm 3 роки тому

    Code Monkey is the best. Thanks, again.

  • @ThefamousMrcroissant
    @ThefamousMrcroissant 2 роки тому +1

    Very concise. This tool seems especially useful for prototyping, but feels a little inflexible when it comes to dynamic terrain.

  • @floriang7
    @floriang7 Рік тому

    I've just watched the video to learn about Unity's navigation and I have a quick question: Currently i'm using a Rigidbody to move a character but I want it to navigate around different obstacles. Do I now use the NavMeshAgent to move the character instead of using the RigidBody?

  • @joepeters8746
    @joepeters8746 3 роки тому

    This video is cool explaining the basics, but how to really use it? How to add e.g. an animation when it jumps from one plattform to another? How to use it with physically driven objects etc.?

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  3 роки тому

      In this video I focused on the basics, I plan to cover more advanced use cases in another video when I make the first course update.

  • @marcelothunder3772
    @marcelothunder3772 3 роки тому

    can u make a video for baking the navmesh while in the game?

  • @benji23245bis
    @benji23245bis Рік тому

    Great video ! But it feels like it's made for non-player characters only ?
    Or is that also how I could make my player smoothly go up stairs ?

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  Рік тому

      You can also use it for the player, either as kind of like an RTS to tell the player where to go, or just ask the NavMesh ifthe position where the player wants to go to is walkable docs.unity3d.com/ScriptReference/AI.NavMesh.SamplePosition.html

    • @benji23245bis
      @benji23245bis Рік тому

      @@CodeMonkeyUnity It's weird because I replicated what you did in the video, except with a cube controlled by me, and the cube just wouldn't go up the stairs :/

  • @roshanthapa1297
    @roshanthapa1297 3 роки тому

    This was very helpful 🙂.

  • @liliaceae2212
    @liliaceae2212 5 місяців тому

    How do you increase speed without sliding too much?

  • @Malkawi_FTP
    @Malkawi_FTP 3 роки тому

    Oh thank you so much,
    That really helped

  • @neos6997
    @neos6997 3 роки тому +2

    Pro tip: if you can’t see the navmesh after baking just make sure gizmos is enabled in the scene view… 🤦‍♂️

    • @sundsalharbi8817
      @sundsalharbi8817 2 роки тому

      Thank you so much, I did not know what is the wrong ! ... thank you

  • @spartadiunruly6212
    @spartadiunruly6212 3 роки тому

    Can you show how to make character selection in new unity input system

  • @shotkill4932
    @shotkill4932 Рік тому

    hello, please tell me why NavMesh UpdateUpAxis may not work?

  • @aleksey2793
    @aleksey2793 2 роки тому

    Hi! Which pathfinding is better for tilemap isometric game? Astar or NavMesh?

  • @AleksanderKamieński
    @AleksanderKamieński Рік тому

    Is it possible to simulate a large number of people leaving a multi-story building using Unity navmesh pathfinding and probuilder?

  • @trebor2485
    @trebor2485 2 роки тому +1

    Would this NavMesh system work with a procedurally generated world? Is there a way to bake the spawning environment as it generates in-game?

  • @FarazKhanDev
    @FarazKhanDev 3 роки тому +1

    WHats the difference between setting an obstacke as static, as you have shown versus adding the "nav mesh obstacle" component via inspector? Thanks

  • @masterank2005
    @masterank2005 3 роки тому +1

    Hi,
    I am a novice unity game developer and I am facing an Andriod Unity Webgl problem where my canvas elements are not getting fit on any android device screen even though I set the canvas scaler to scale with the screen size. I went through a lot of documents but I couldn't figure out the answer. Please help me solve this issue as I worked really hard on that game.
    Please Help!

  • @shanmukhajagadeesh
    @shanmukhajagadeesh 3 роки тому

    Awesome. could you please make a video on Vegetation studio pro.

  • @Duck-ue3vn
    @Duck-ue3vn 2 роки тому

    thanks

  • @haxic
    @haxic 3 роки тому

    Thanks!

  • @zildeos9858
    @zildeos9858 3 роки тому

    Great video as always
    Also can you make a video for working in with the ide cause every other tutorial is taking about the text editor instead of the actual ide thanks

  • @gargaroots
    @gargaroots 3 роки тому

    Amazing overview! Thanks a lot man! =)

  • @DARTEKZgamez
    @DARTEKZgamez Рік тому

    why i dont have links shown for drop and jump?

  • @harshadagorey
    @harshadagorey 3 роки тому

    Nice one

  • @robertogirardi6861
    @robertogirardi6861 3 роки тому

    Navmesh work for 2d or only for a 3d game?

  • @ajinkyax
    @ajinkyax 3 роки тому

    you should bring a course on Unity 3D state machine, Im a new to unity, but having made a simple player controller and NPC, NPC needs some brain now

  • @Cendimix
    @Cendimix Рік тому

    The drop and jump isint working, what do i do?

  • @ROUGETHEBAT456
    @ROUGETHEBAT456 Рік тому

    I don't have the bake table only navigation what do i do

  • @thite2542
    @thite2542 3 роки тому

    hello can i ask something why my navmesh can't run into clone from selected character?

  • @abdou023
    @abdou023 3 роки тому

    How to make the unit stay on the center of the path even in corners?

  • @adm1n901
    @adm1n901 3 роки тому +2

    I was wondering how to do this in 2D. is it possible to do navmesh in 2d or just 3d? 2d topdown specifically.

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  3 роки тому

      Unity's NavMesh only supports 3D, that's why for my 2D games I normally either used my own custom Pathfinding or the A* Pathfinding Project
      ua-cam.com/video/46qZgd-T-hk/v-deo.html
      ua-cam.com/video/alU04hvz6L4/v-deo.html

    • @adm1n901
      @adm1n901 3 роки тому

      Thanks!

    • @rameshkrishnan3020
      @rameshkrishnan3020 3 роки тому

      @@adm1n901 github.com/h8man/NavMeshPlus use this for 2d navmesh

    • @annakontou5584
      @annakontou5584 3 роки тому

      In my opinion you could just turn the camera from the top so it will look like 2D.

    • @adm1n901
      @adm1n901 3 роки тому

      Tysm fusion

  • @megax940
    @megax940 3 роки тому

    Any tip on how to add a second "Agent" and baking it to the navmesh?

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  3 роки тому +1

      I'm not sure what you mean, agents aren't baked into the NavMesh, they traverse it. You just create another object with an Agent component and it will traverse the navmesh just the same. Maybe play around with the options I mentioned so it moves through different areas.

    • @megax940
      @megax940 3 роки тому

      @@CodeMonkeyUnity I was a bit dumb... hehehe You can add other schemes but by default it bakes human and you can adjust, the raius and stuff, on the NavAgent itself. I Was creating another Agent Type but for this it needs the Navigation package and custom bake to work :)

  • @Forjugadname
    @Forjugadname 3 роки тому

    Really cool tutorial, I'm curious if you know of a way to use the navmesh with entities or jobs in some manner.

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  3 роки тому

      I did cover interaction with Game Objects and DOTS quite a while ago ua-cam.com/video/XomlTHitAug/v-deo.html
      It's been a while since I made that video so not sure if there's a better method nowadays.

  • @vitaminaninja
    @vitaminaninja 3 роки тому

    Coud you make an tutorial on Unity 2D?

  • @xenoaisam
    @xenoaisam 3 роки тому

    Ultra Advance tutorial : Unity Navmesh on Elevator :)

  • @louisforlibertarian
    @louisforlibertarian 3 роки тому

    Absolutely love this type of video!
    And I have a quick question - if I am working on a project that involves the 3d navigation of a robot in outer space, can NaveMesh still function properly?

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  3 роки тому

      Do you mean baking a sphere navMesh? I don't think the default NavMesh supports that, I think you would need to manually stitch multiple meshes together

  • @_CloudyBunny
    @_CloudyBunny 3 роки тому +1

    But how to make the agents be able to jump onto a higher ground?

  • @parthacodes5893
    @parthacodes5893 Рік тому

    In my game to bake the terrain it is taking a time of 1and half hours

  • @JoeyHauschildt
    @JoeyHauschildt 3 роки тому

    Can you bake the navmesh at runtime? Can I change agent settings through a script?

  • @robs5532
    @robs5532 3 роки тому

    Is there any way to generate off mesh links for jumping up? with a max jump height? To allow agents to jump up or climb up to another mesh

  • @pliniomourao
    @pliniomourao 3 роки тому +2

    How do i Bake the scene through code?
    Lets say i procedure generate my scene and set the static mesh of my scene... How to Bake using the code?

    • @EskChan19
      @EskChan19 3 роки тому +2

      You can add the NavMesObstacle Component if you want things to be considered an Obstacle during runtime, that's useful for example when you build a strategy game so units don't walk through buildings you build. If you want to bake an entire navmesh during runtime then Unity can't do that by itself, but there's a plugin called High Level Navmesh Building Tools that you can download from Unity to add components that you can add to gameobjects through code to make them considered for navmesh.

    • @pliniomourao
      @pliniomourao 3 роки тому

      @@EskChan19 thank you so much.
      I will look into the tool and make tests. Thanks

  • @jamestrollol1055
    @jamestrollol1055 3 роки тому +1

    can u make a tutorial on how to make tycoon games

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  3 роки тому

      That's a topic I'd love to cover some more, I did some videos back when I was working on Battle Royale Tycoon ua-cam.com/video/rQXr9XTu6CI/v-deo.html