AstarAI flicker when repathing

Hello, I’m using the example AstarAI.cs as a baseline for future modifications, but a issue I’m having is the character stutters violently when a repath is requested, and also has a difficulty going up ramps. If I set the repath rate to something large, such as every 2 seconds, it happens less frequently, but still does so.

Example behaviour:

(Ignore the second graph, it was a test I forgot to remove. First video has a cut in the middle)

The code is the same as https://arongranberg.com/astar/docs/_astar_a_i_8cs-example.php, except for formatting style convention.

What is going on here?

Hi

The AI script written in the get started tutorial isn’t very advanced. What happens here is that the agent requests a path, but that path takes a few frames to be calculated so when the OnPathComplete callback is called the agent has moved a small distance and is no longer at the start point of the path. This may cause it to turn around to walk back to the start point (which is what you are seeing as stuttering). The movement scripts that are included in the project (AIPath in particular) handle this case in a better way. You can try to use that script instead.

1 Like

Ah, that makes sense. Thanks for the timely response!