A* Pathfinding Project

How to recalculate moving target with AI Path?


I’m using the AI Path script to move my AI to the player, but it does not recalculate the path while the player is moving. Adjusting the repath rate doesn’t help, it simply doesn’t recalculate again until the player stops moving.

Any suggestions to have it follow a moving target?



The repath rate determines, how frequently it recalculates the current set destination.
You might want to look at your code that sets the destination.


It’s the standard AI Path, AI Destination Setter, and Seeker scripts. I haven’t modified them.

All my code does is enable the AI Path script on awake and disable it on death.



Hmm, the default Destination setter does update the destination every frame

void Update () {
	if (target != null && ai != null) ai.destination = target.position;

I tested this in the RecastExample scene and it moving the continuously moving the target worked.


I moved the code that enables the AI Path from FixedUpdate() to Update() and it seems to have resolved the issue.

Thanks for your help!