- A* version: 5.3.8
- Unity version: 6.0
Hi
I’m trying to create an enemy type which only moves near the edges of the navmesh while in its neutral behaviour. During this it wouldn’t need to have any pathfinding, rather it would just find the closest edge of the navmesh it is currently on, and start moving along it.
I am aware that this could be achieved with physics queries, however I would much rather have it directly query the navmesh.
I’m using a recast graph, and the agent would preferably be FollowerEntity. I have used the ITraversalProvider and movementOverrides previously for different purposes, however I have trouble imagining how to achieve what I want with those. After all, I’m not strictly looking for paths to anywhere, but just direct access to the nearest nodes on the edge of the graph.
Right now I’m thinking something like this:
- If the agent is not near to the edge of the navmesh, find the closest node to the agent that is on the edge of the navmesh. If it is already near the edge, iterate over nearby nodes to find the next edge node, preferably in front of the agent.
- Get one of the edges of it that’s actually on the edge, not the ones adjacent to other nodes
- Get a position along that edge
- Set the destination of FollowerEntity to said position
I can’t figure out how to directly query nearby nodes like that. I’m aware of AstarPath.active.GetNearest but it doesn’t provide enough customization to handle something like this afaik. So, how could I do that? Or is there some different way to achieve what I want?
Thanks