Hello again,
I'm having some problems with Mesh Collider Pathfinding.
- The player walks out of the Mesh Collider and crosses over "empty" space to find the target.
- The Pathfinding does not use the most direct route and makes unpredictable detours.
I've created the Mesh in Blender. It is just a plane and enabled read/write after being prompted to do so.
- Is there a way to limit the distance for pathfinding? So that the user can not click at the end of the map and watch the player make the whole way?
- Is there a way to set borders to the mesh, so that the player keeps his distance from the edges?
Thank you all
Comments
Check that the mesh's faces are all facing the same way. However, it may be that the mesh itself is too complex for the algorithm - Unity's built-in Navigation feature is the recommended method for 3D scenes.
You can use your custom mesh as the basis for the baked Unity NavMesh by marking it as "Navigation Static" - if you reduce the Agent Radius in the Navigation tab, it'll occupy the same space as the mesh. A tutorial on this topic can be found here.
You can hook a custom script into the OnPointAndClick custom event, which provides the array of points to traverse, and then modify those points to all be at the Player's position:
The NavMesh itself needs to be thinner. If you use a baked Unity NavMesh (see above), you can increase the Agent Radius to increase the margin between the edges.