How can I debug or find out the reason why some NPC's stop walking?

(noah) #1

I’m dealing with a problem where some NPC’s stop moving/walking when they are on their way to their destination.

A group of 10 NPC’s are ordered to walk from a point where they were created to an specific point. If I send the order/request to move to a point to all 10 NPC’s, they start walking but at some point as they are tightly together on a corner, one or two of the NPC’s simply stop walking/moving. It sort of feels like they block each other, because usually the ones who stop moving are the ones behind in the pack.
If I order them to move to that location but leaving a 2 second space between commanding each NPC, they walk all the way to their destination with no problems, but this is not the desired behavior game mechanics-wise.

The NPC’s are using nav mesh agents (on a nav mesh of course), nothing external attached, everything is from plygame components.

Any ideas about what could be the problem or how can I debug to know what’s causing the NPC’s to stop walking/moving? It is not throwing any warnings/errors to the console.


(Leslie Young) #2

They probably got “stuck” long enough for the agent to give up and plyGame is not reissuing commands to move cause it does not know the agent gave up.

I’ll see if there is something that can be done.

(noah) #3

Hi @leslie ,
I just managed to “fix it”, even though, it looks more like a situation related to Unity as is, and not plyGame related I guess.
It’s tricky to explain, but it was related to the navmesh (the light blue “walkable” areas) on that specific location of the map, because there the navmesh was “subdivided”, this is, not perfect squares from corners to corners, so it draws other lines creating subdivisions as triangles, but still, it is a contiguous navmesh polygon.
Here’s what I’m talking about, maybe it explains it better (you can see those little lines creating small subdivisions under the red dot/NPC):

I aligned the walls of the buildings in that area so the corners of them match, baked the navmesh again and there were no more subdivisions in that navmesh area. I sent the NPC’s to walk it and no more getting stucked. Because all NPC’s try to walk the shortest path, some eventually get pushed to that portion of the navmesh, but now that it is not subdivided, they simply keep walking and then reincorporate to the shortest path when they can.

I’ve been testing it and all good now with that small change. I’ve been checking other areas of the map to see if the navmesh is acting funny.

Thanks :slight_smile:

(Leslie Young) #4

Interesting. I am still going to look at detecting NPC that did not reach end-point and is no longer moving, Just got a bunch of other stuff to finish 1st over weekend. Hopefully I can get to this on Sunday or Monday.