I have an AI character that has a custom AI controller which uses AAIController::MoveToActor to chase the player.
This works great, unless the player character jumps over a gap in the map.
It looks like MoveToActor only works if the target (the player in my case) is on or close to the navmesh. Once it’s not, MoveToActor returns OnMoveCompleted with the result being IsFailure.
As soon as my player lands on the other side of the gap he was jumping, MoveToActor works again and the AI runs up to the edge of the jump. I haven’t set up any NavLinks yet so he stops at this point.
My first thought was to use ProjectPointToNavigation if the AI loses the player so he can at least run to the closest point on the navmesh to the player with MoveTo(), while checking every half second or so to see if he can continue the chase with MoveToActor.
This seems to work ok, however, there is a pause and my AI stops moving for a tiny bit when this first switches over which looks bad.
Next I tried using MoveTo all the time so the AI always moves to a point on the navMesh that is close to the player by still using ProjectPointToNavigation to get the target point. This worked really well except that the movement seems different when I use MoveTo() vs MoveToActor(). It looks like MoveTo is less aware of other characters and when there is a group of them, they push each other sideways and it looks bad. I don’t see this with MoveToActor?
My next plan is to try a similar approach but instead of MoveTo, I will use MoveToActor and set up a dummy actor that follows the main player using ProjectPointToNavigation. My AI can then follow this dummy actor using MoveToActor().
As I was about to start on this, I thought it seemed like a bit of a bodge job and thought I must be missing something?
So, my question is what am I missing? How do people make AI chase the player without getting pushed around or stop following when the player jumps over a gap etc?