How do I stop NPC Seek due to elevation difference?

YaquiKnow

New member
Using the BD in the UCC/BD Integration Demo, I have a NPC patrolling on top of a shipping container. If the player shoots, the NPC will seek the player and run off the container. The picture below shows the NavMesh on and around the container - I thought that would prevent the NavMeshAgent from moving off the container. I want the NPC to Seek the player and come to the closest point on top of the container while preventing him from taking the step that drops to the terrain. So, a simple elevation diff between NPC and target won't work. What is the best way to get him to move as close as possible without stepping beyond the edge of the Navmesh?

1647995365703.png
 
I thought that the NavMeshAgent already moves to the closest point if the navmesh is at an invalid position. But if it's not working the way that you'd expect you could subclass the seek task. From there you can use the NavMesh API to get the hit elevation and if there is too larger of a difference then you stop the seek.
 
Top