Trouble calculating new path for currently pathing GameObject

Hey so I’m kind of struggling to deal with generating a path for an already pathing unit and waiting for the callback. My units are controlled through a Rigidbody character controller. I’m just using A* pathfinding to generate the path, and then I throw the direction for that frame into their character controller. I’m not using any of the built in movers.

The issue I’m having is that a unit will have a path and be moving towards a target (usually a moving target). A request will be made for a new path, a few frames will pass, and the result will come in. By this point the unit has moved further down the initial path. Immediately swapping to this new path will result in the unit backtracking a bit because the new path was requested was from the position it was at frames ago.

Any suggestions?

Few things you could try:

  1. Increase the amount of threads used for pathfinding - Might speed up the path calculations, thus leading to less backtracking
    image
  2. Make the unit stop in its last position before new path has been received
  3. Force the path to be calculated on the same frame as the request is sent (might lead to freezes during gameplay if used too much)

read this: Searching for paths - A* Pathfinding Project

I’ll look into these options, but how do the built-in movers handle this? I can attach a AIDestinationSetter and they seem to constantly adapt to the new target location fine without stopping. Do they also immediately request a path and not bother with a callback? Do they not kill the framerate because they request the new path infrequently?

In my case I have about 200ish units. They obviously do not need to generate new paths every frame.

The built-in movement scripts immediately repair their path when it comes in after a few frames to avoid this issue. It can still happen if the agents move very quickly, though.
The AIPath script always tries to move toward a point a small distance in front of it.