Support Forum

Path Failed : Computation Time 0.00 ms Searched Nodes 0

unity v2021.1.21f1/BIRP
astar: 4.2.18 (Current) - released on November 08, 2022

I spawn a bunch of RichAI in waves for a tower defense.

Each spawn I get that warning for every AI, and after a couple waves I start getting 100’s of them.

At one point I had 2 graphs, but have reduced testing down to 1 graph and put each Seeker’s TraverseGraphs set to Everything.

Doesn’t seem to make a difference which graph I select (explicitly select the recast graph or just go with Everything).

The AI start off ok getting their target, path, and seem to be moving correctly, but after a few spawns more and more AI just sit there without showing a path.

The warning usually says Computation time 0 but not always.

image

Hi

This is most likely because you are calling ai.SearchPath() faster than the agent can calculate its path. If a path request is pending when ai.SearchPath is called, then the previous path request will be aborted. You can check if a path is pending using ai.pathPending.

Adding a check for agent.pathPending() cleared up warnings for my wave spawn, thanks!

All of my ai are using the same MoveTo task in their behaviour trees (Opsive)

I am still getting that same warning occasionally when I spawn my worker drones (4 on screen). The problem now is the warning is not consistent and isn’t happening very much so it’s difficult to track down where and when it is happening. Is there a recommended way to track down which agents are causing the warnings?

The MoveTo and behaviour tree code is pretty simple. Find a target, move to it, do work on it until finished, then either find another target and repeat or go idle.

MoveTo only makes calls to check if HasArrived or SetDestination.

        protected override bool SetDestination(Vector3 target)
        {
            if (agent.pathPending) return true;

            agent.canSearch = true;
            agent.canMove = true;
            agent.destination = target;
            agent.SearchPath();
            return true;
        }

Hi

There must be some other code running. Just the code that you posted will never cause that warning to appear.

Checked everything and can’t spot any extra code running.

It only happens when I have multiple drones running the same behaviour.
They all have the same simple behaviour tree (find target, move to target, interact with target until finished).

I’ve changed the MoveTo code to call SetDestination on a timer which is set to every 5 seconds and I still get warnings. It seems to be happening on any drone and is still seemingly random.

I also added code to abort SetDestination if the target hasn’t changed, still get warnings.

        protected override bool SetDestination(Vector3 target)
        {
            if (agent.pathPending) return true;

            if (agent.destination == target)
            {
                Debug.Log("Target unchanged, abort setdestination");

                // no change in target, abort
                return true;
            }

            agent.canSearch = true;
            agent.canMove = true;
            agent.destination = target;

            if (agent.destination == null)
            {
                Debug.LogError("agent.destination is null");
                return false;
            }

            agent.SearchPath();
            return true;
        }

Any other suggestions how to track this down? I wouldn’t care as it’s just a warning but when I was getting too many of them with my wave spawn it was breaking their AI pathing.

Think I found it, there was a call to SetDestination in the behaviour’s Start method as well as during update, which was bypassing my timer, but I would have thought my check for if the target was changed would have prevented it.

Oh well, seems fixed :slight_smile:

1 Like