Get Path Length - Inconsistent Results

Hi,

Currently setting up a Behaviour tree and trying to put in a few IF’s or AND’s statements to try and control the AI’s behaviour, I am finding that the “Get Path Length” node is behaving slightly randomly and sometimes I find i get results of 0 even though the AI moved 20 or so units before the last execution.

Image: [][1]

That displays the nodes in and around get Path Length, I’ve read up a bit around the site, and apparently it was improved in 4.2? Not sure if that is true, or whether its just I don’t full understand the results its trying to give me

I saw an alternate method by subtracting the Vectors of both Actors, but the results are about 10 units or so off, So its just a bit annoying,

Any advice?

Thanks

[1]:

Hi Nemecys,

In general GetPathLenght returns an approximation of path length rather actual length. It’s an optimization, this function is skipping one expensive step of pathfinding to save some CPU cycles. Having said that maybe this behavior should be optional…

One more thing here. I’ve looked at the code and it seems there’s a bug in path length calculation when start and end point are on the same navmesh polygon. In such a case the function will return 0 while it should return distance between start and end points. Will fix it. Thanks for reporting it!

Cheers,

–mieszko

Is this bug still in the release version of the engine? I’m running into an issue where I’m always getting 0 returned by this node. ‘Move To’ nodes work fine between these two actors, but get path length isn’t giving me a proper value.

Yo MieskoZ, I’m assuming this was fixed since I didn’t have any problems when I tested it. Can you see whether the same bug is also in the Get Path Length node as well? I’m getting pretty much the same problem just with the path cost node instead.
I’ve put it in a separate post here: Get Path Length/Cost is 0 - Programming & Scripting - Unreal Engine Forums to report it as a bug, however since you seem to have found a solution for it I thought I’d post here as well.

Indeed the bug is there. Will have it fixed shortly.

Still waiting for it to be fixed, since I just run into this bug today…

me too T.T

Hi everyone:

I’ve reached this post trying to find out why GetPathLenght is returning me a 0.0 value. My scenario was starting my level with my pawn in top of a building and all other enemy characters below it. At begin play, all my enemy characters detect my pawn directly althought I’ve setted detection distance to 1 in its presence detection task included in its Behaviour Tree. investigating this issue, I’ve noticed that GetPathLength is always returning me 0.0 value, so enemy characters always take attack state in its behaviour tree (just as in case that have pawn side by side) and never takes the patrol state branch as they must when a pawn is not in sight. After a few tests, I’ve discovered that the main reason for this issue is that navigation mesh RecastNavMesh is not covering my buildings roof height so that enemy characters are all navigating in that RecastNavMesh and Pawn is not included in it ( pressing P in edit mode to see RecastNavMesh boundaries). After all, its clear to me that GetPathLenght is not working properly when this situation occurs and if we want to solve that kind of situation, we must grant that RecastNavMesh cover all these excluded areas that main pawn and enemy characters can explore in navigation. In mi case, the solution comes adjusting height of RecastNavMesh to cover the roof areas so that main navmesh include roofs (Just in case roofs have physical connection with floor trough ramps or scalators), Other option is to add extra code in my detection task to avoid the execution of GetPathLenght when height difference between pawn and characters is out of bounds (Just in case when pawn is in that roof and have no physical connection with floor to set the navigation path between both areas), avoiding enemy characters in detect pawn presence.