I have some scaffolds that the player can walk up using a ramp. The scaffold is about 2 meters above the floor. The player can also walk below the scaffold.
The AI however has a problem with this:
if the player is up on the scaffold, and the AI is down on the ground level,
instead of moving up the ramp to get to the player on the scaffold, it will walk
under the scaffold and stop right below the player.
I suspected the problem is that this point is within the end reach distance, but it happens
even if I reduce the end reach distance to 0.5.
Are you sure the player’s position is reachable for the AI?
The ai always moves to the closest position to the destination that it can reach.
The generated graph covers all of the ramp and the upper level of the scaffold, so it is reachable.
I should also mention that sometimes the AI choses to walk up the ramp and take the correct path.
But sometimes it just walks below the scaffold and stays beneath the player.
Try to debug which point the AI determines is closest using something like:
var nearest = AstarPath.active.GetNearest(player.position, NNConstraint.Default);
Debug.DrawLine(player.position, nearest.position, Color.red);
Could this be due to funnel simplification being turned on?
I turned it on because otherwise the AI will not take direct paths when
using a grid.
Most likely not, but feel free to try to turn of it off.
I tried it with the Debug.DrawLine: when the player is on the scaffold, it correctly determins the nearest position to be right where the player is at.
But the AI will often flip between going below the scaffold, or going up the ramp.
It might go up the ramp for a while, then turn back and decide to go below the scaffold.
Do you have a video of this happening?