Need to stop an agent cold (reset/clear path)

Long time reader, first time poster!

After much recommendation, I made the leap and converted my game project over to A* from the built-in Unity NavMesh system. I extended the RichAI class to create something that more or less followed the same patterns as the old NavMesh agents.

I’m running into a problem (which must be obvious and I’m somehow missing it) in that I need to stop my agents cold and clear reset/clear their pathing. My game is a multiplayer (client-server) game with turn based combat, and agents have to be prevented from moving further than their allowed. Additionally, move corrections are sometimes sent from the server.

In the old Unity system I would call ResetPath(). I implemented the following to simulate it but it’s not working:

public void ResetPath()
    {
        if(_navigatorStatus != NAVIGATOR_STATUS.ON_PATH)
            return;

        destination = new Vector3(float.PositiveInfinity, float.PositiveInfinity, float.PositiveInfinity);

        seeker.CancelCurrentPathRequest();

        _navigatorStatus = NAVIGATOR_STATUS.IDLE;
    }

Hi

The intended method for this is ai.SetPath(null).
See https://arongranberg.com/astar/docs/iastarai.html#SetPath

Works like a charm! Thank you sir :smiley:

1 Like