I have an NPC traversing the level, going from the bottom floor, up a staircase that is shaped like 2 L’s facing each other (see images). He walks up fine, however, when he reaches the equivelant of where the stairs start again, but above, he tries to turn around and go up the stairs again, instead of moving forward.
If i put another point in the middle, causing the NPC to search just halfway, and then search the rest from the top, I don’t experience this issue.
Can you shed light on why this is happening? how can this be fixed? accounted for?
How can I get the seeker to search the path in parts?
Hm… I am not sure what could be wrong…
If you try to set the repath rate on the RichAI to some very high value so that the character does not recalculate the path while following it, does that change anything?
Hm… ok, then it is likely that it finds the wrong start node during the first path request.
If you position the character somewhere else in the level and try it, does the same thing happen?
I have a feeling this has to do with the difference in heights. I’m not really sure on how the internal workings of the buffer, funnel and path class are.
It just feels like it it picks the wrong next point, making the NPC try and go back up the stairs, even though he is already up.
Like I suspected, he tries going to a point on the stairs below again.
I did notice this time around (no updates have been done to code, perhaps some to the navmesh) it took a few runs around his patrol before he got stuck there.
Ok. When he travels up the stair (not yet stuck), does it look like he is moving towards the correct points (using the debug code you added previously) or is he always moving towards points one level down?
After some thinking and experimentation I think I know what might be causing it.
The RichAI agent always tries to look for which node it is currently standing on, sometimes this node might not be what it expects, for example it might have been pushed off a cliff or something, and then it shouldn’t just continue as if nothing had happened. In this case I think it steps a very tiny amount outside the navmesh at the top, it then suddenly finds that it is inside a node one stair down (it is checking in the XZ space) so it will continue the path from there. This is obviously not what you want in this particular case.
I have modified the RichPath.cs script. I am not quite ready to release an new update to the package with it because there might be edge cases I haven’t thought about, but for your case I think it should work a lot better.
Here is the script: http://pastebin.com/1ziLzCMr, it should be a drop in replacement.