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"
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
3. For everything else that moves (and does not contain a NavMeshAgent ), add the "Nav Mesh Obstacle" component to it.
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 .
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
留言