Sample NavMesh Positions PER AGENT TYPE Using NavMeshQueryFilter | Unity Tutorial

Поділитися
Вставка
  • Опубліковано 6 лип 2024
  • In this tutorial you'll learn all about NavMeshQueryFilter and how to use it to distinguish between different baked NavMeshes that are baked per Agent Type using the NavMeshSurface component.
    👨‍💻 The full project for the Chicken Defense Microgame is available on GitHub for FREE: github.com/llamacademy/chicke...
    🎮 Play Chicken Defense FREE on Itch.io: llamacademy.itch.io/chicken-d...
    🏷️Save 25% on the ultimate C# IDE: JetBrains Rider with code LLAMACADEMY: www.jetbrains.com/store/?sect...
    📚 Resources:
    ⚫ NavMeshQueryFilter Docs: docs.unity3d.com/ScriptRefere...
    ⚫ NavMesh.SamplePosition Docs: docs.unity3d.com/ScriptRefere...
    🧡 Believe in LlamAcademy's mission and have received value from the videos? Here are some ways you can show your support:
    📚 Take my Unity ShaderGraph Course:
    www.gamedev.tv/p/unity-shader...
    👕 Get yourself some LlamAcademy merch: llamacademy.myspreadshop.com/
    Become a Supporter:
    🌟 Patreon: / llamacademy
    🌟 UA-cam Member: / @llamacademy or click the Join button on any video
    🌟 GitHub Sponsor: github.com/sponsors/llamacademy
    Use these affiliate links to do your Asset Store / Humble Bundle Shopping!
    💸 Check out the latest Humble Bundles www.humblebundle.com/software...
    💸 Publisher Sale! 50% OFF an entire publisher's Assets! Publisher changes weekly! assetstore.unity.com/publishe...
    💸 Save up to 50% on NEW Assets: assetstore.unity.com/?new_sal...
    Some links may be affiliate links, which at no additional cost to you, gives me a small portion of the purchase.
    #unitytutorial #tutorialtuesday #gamedev #tutorial #unity #llamacademy #gamedevelopment
    Chapters:
    00:00 Topic Introduction & Problem Statement
    01:13 The Solution - NavMeshQueryFilter
    02:10 Scene & NavMesh Configuration
    02:43 How to Use NavMeshQueryFilter
    03:47 Closing Thoughts & Support LlamAcademy

КОМЕНТАРІ • 11

  • @afk1466
    @afk1466 4 місяці тому +1

    awesome!

  • @Dippps
    @Dippps 4 місяці тому

    yes thats what i need. i have golems in game and they are big

  • @TheKr0ckeR
    @TheKr0ckeR 4 місяці тому

    Thanks for great guide! I always had a problem about that. For example, i have some customers that can come from many side from our bakery. But I dont want to allow my player to leave our bakery, They are both moved by navmesh component and they use same navmesh surface which is the total area.. Even if i bake for different navmesh surfaces, (which looks for children mesh), my player can still be able to walk around customer's areas. Does this NavmeshQuery helps me to solve that? How would you achieve something that AgentA can walk in AreaB but AgentB shouldnt walk in AreaB? I would be really appreaciated if you explain how would you approach that. I have tried many solutions but ended up using obstacles which needed to reposition my customers.. So customers would only walk where player walks. :(

    • @LlamAcademy
      @LlamAcademy  4 місяці тому +1

      For that use case I would bake 2 separate NavMeshes using 2 different NavMeshAgent types even if their configuration is the same. For the customer areas you can put them on their own layer and exclude that layer from the Player NavMesh bake. You could also attach NavMeshModifiers to the walkable areas for the customers and exclude them from the bake of the Player NavMeshSurface.
      Depending on your level design, you can change the NavMeshSurface bake type to Volume, much like how the chickens are done here, to only allow them to walk within a small area. This requires you have a rectangular area for the player though. The other options will work reagardless of the level design.

    • @TheKr0ckeR
      @TheKr0ckeR 4 місяці тому +1

      I did exactly what you have said with modifiers, selecting agent type and excluding others but something didnt go right. Can you try this in your free time if its working successfully with modifiers? I have created navmesh surface and baking children. and i selected customer area, and add navmesh modifier, override area and select type of customer. And set customers agent type in navmesh agent and i have excluded player inside agent and modifier. But ended up customers having error of activd agent surface couldnt find or similar when a navmesh cant find a navmesh surface in ground. I wonder what might went wrong. If i bake them all without modifiers, evertyting works but i cant prevent player walking through customers area

    • @Eculeus007
      @Eculeus007 4 місяці тому

      @@TheKr0ckeR Have the same problems with Navmesh Modifier.

    • @LlamAcademy
      @LlamAcademy  4 місяці тому

      If I read that right, I think you configured it backwards. You want to exclude the customer area for the player walking on it. So on the outside you would have modifiers saying exclude for player.

  • @artinstroukeprod
    @artinstroukeprod Місяць тому

    How to specify specific custom "NavMeshArea" in QueryFilter? Not "Walkable" \ allTypes

    • @LlamAcademy
      @LlamAcademy  Місяць тому +1

      You can use the helper NavMesh.GetAreaFromName
      for other area types. docs.unity3d.com/ScriptReference/AI.NavMesh.GetAreaFromName.html

    • @artinstroukeprod
      @artinstroukeprod Місяць тому

      I tried this (NavMesh.GetAreaFromName). However, it didn't work for me due to the "Walkable" in the scene. And it was always taken as priority by default, ignoring the mask. When I replaced Walkable with custom area, the taco option worked!

  • @beckett3859
    @beckett3859 2 місяці тому

    *promo sm* 😴