Paths stop generating based on NPC count

Hello,

The issue is basically that at some point, paths just stop being calculated for newly spawned NPCs. The number of NPCs can be in the hundreds, and so in debugging I limited it to around ~200, which seems to be around when it starts happening.

Proximity to the NPCs doesn’t seem to matter.

When I start deleting NPCs, the inactive ones suddenly start calculating paths.

When I toggle AIPath on and off during runtime on an affected NPC, it also calculates it’s path.

All NPCs being spawned are clones, so settings are the same.

I do see a warning being generated (shown in screenshot below), but I am not sure if it is related, or why it is being generated.

I am experiencing zero lag or anything that suggests I am exceeding my available memory. I’ve also tried optimizing the settings as much as possible, as the level of movement realism and even collision detection, isn’t really that necessary for what I’m doing at the moment.

I’ve looked through all of the settings to see if there’s a limit on the # of paths somewhere, but couldn’t find anything.

Here is a screenshot of my settings. You can see many paths being calculated, but there are some yellow clusters where no paths exist.

I’m not sure where to go from here, any direction would be appreciated, thank you!

Hi

Do you call ai.SearchPath() at any point?

Disclaimer, I am using Behavior Designer, and but I am pretty familiar with it, both front and back end and have confirmed the issue does not appear to be related.

In Behavior Designer I have a Seeker behavior, which is executing successfully. On the start of the behavior, it calls a function that looks like this:

    protected override bool SetDestination(Vector3 target)
    {
        Debug.Log(gameObject.GetInstanceID());
        Debug.Log("Target is" + target);
        ai.canSearch = true;
        ai.canMove = true;
        ai.destination = target;
        ai.SearchPath();
        return true;
    }

I have confirmed that the affected GameObjects are indeed calling this function, and that the target coordinates are being passed through correctly via those debug logs. The issue starts occurring when I’ve exceeded around ~150 Game Objects. If I delete the objects in the scene that are working, the ones that aren’t immediately start to calculate their paths.

I am still not able to find a solution to this problem. My temporary fix is just deleting the GameObjects that do not generate a path, but obviously that is poor workaround.

If I need to provide any more data or set up more exclusive tests, I am more than happy to do the legwork. Just let me know what you need.

Hi

Do you call SetDestination repeatedly? If ai.SearchPath is called and it hasn’t yet completed its previous path search, that search will be aborted. So if you repeatedly call ai.SearchPath without giving it time to calculate its path, it will never get a completed path to follow.

That was it! Thank you. I implemented a check for that and now I am free to lag my computer to a standstill :joy: I will reach out to the Behavior Designer developer and suggest an improvement to his code to hopefully prevent people like me from ending up here in the future :stuck_out_tongue:

1 Like