Find a new path mid game

To Mr. Aron Ganberg the Author of A* PAthfinding Project.
Dear sir.
MY problem is pointed out below.

Each enemy starts from a home position.
They all target the same object the Player.
How do I calculate a path back home for each enemy if the player is out of range?
Do I have to calculate 1. a path from the enemy to the player, 2. a path from the enemy to home in a timed loop?

How to get about doing that?
Some help would be appreciated.

I hope someone will answer this. The package is good but the lack of tutorials and lack of proper response to the questions make its value diminish. Having several undocumented scenes doesn’t fill the gap of at least one or two complex tutorials, video, or text.


If you use one of the built-in movement scripts you can just change the destination of your agent whenever the player is out of range. Something like:

void Update () {
    if (playerIsInRange) ai.destination = player.position;
    else ai.destination = home.position;

(this assumes you do not use the AIDestinationSetter component, as that will otherwise override the destination)

took a reference to the Destination setter in the Start method and then set the target in code in my event action.

That helped.

1 Like