top of page
Writer's pictureShibaCode

Unity NavMeshAgent Quick Setup

Updated: Dec 4, 2020

Playing around with NavMeshAgent to create some pedestrians in my town.


here's a Quick Setup Steps: 1. Mark everything with a collider that doesn't move as "static"

Baked area shown in blue

2. Create a NavMesh Baked Area for those "static" object - Windows > AI > Navigation - Bake menu > click "Bake" this will create a walkable area for our NavMeshAgent

NavMeshObstracle Component

3. For everything else that moves (and does not contain a NavMeshAgent ), add the "Nav Mesh Obstacle" component to it.



NavMeshAgent component

4. Create NavMeshAgent component on our moving NPC

Note: NavMeshAgent also works as NavMesh Obstacle, therefore, no need to add NMO to the object with NavMeshAgent .


call for SetDestination(V3)


5. Add Script component and call for navMeshAgent.SetDestination(V3 position) 6. DONE!! NavMeshAgent can now move around the scene.







Tips : 1. Set NPC's Rigidboy to Kinemetic will save you from headaches. 2. You can put SetDestination(V3) in Update() loop if your destination is moving. Just note that it's not effective to put a pathfinding function in frameloop(especially for mobile). #Unity #NavMeshAgent

37 views0 comments

Recent Posts

See All

留言


Post: Blog2_Post
bottom of page