AIPath works correctly on first 110 spawned objects, but by 120 or so, starts behaving erratically

My scene is identical to the first “Getting Started” tutorial, except that my cylinder/character is using AIPath to move. I have set it up so that new objects are periodically spawned, by instantiating new clones of a template object. Their target is then set to be a sphere that follows the mouse around.

It works perfectly until a certain number of objects are spawned, after which the objects begin moving in circles and back and forth instead of following the mouse. The problem would seem to be memory related, because the threshold after which the objects start freaking out is lower if I have other programs open, even just my web browser. (Though performance shouldn’t be a problem. I have an Intel i7 x980 @ 3.33 GHz and 18 GB RAM).

It does however seem to be a hard threshold (the change happens after 1 or two extra objects are instantiated) and the problem is repeatable. Also, the paths are redrawn fairly quickly and normally (with a repath rate of about 2), until the freak out happens, after which they take much longer to be redrawn and and sometimes do not appear to be correct at all.

I would just like to know if I am doing something incorrectly, or else how this could be addressed? Is there a recommended/best practice way for creating large (200+) hordes of AIs that will follow a character around, but move individually rather than as units?

I had this problem too, but I solved it by increasing the allowed computation time from 1ms to 10ms. You can find this option in your AstarPath object under Settings and Max Frame Time. Good luck!

Alas, changing the computation time made no difference whatsoever. But once I was in the settings, I changed the thread count from none to 1, and that fixed it !

Aaand, it still happens, but the limit has increased from 120 to somewhere around 200. It seems that there is a limit to how many paths each thread can handle. (Which totally makes sense.) Still, this is drastic improvement :slight_smile:

Where can I see the thread count. I went to settings but there is only a checkbox for multi-threading but no thread count

Hi dees01,
I don’t have it open right now, but I think it is in the inspector when you click on your A* node, somewhere under settings.