v3.6 Recast problem (Unity v5.0.1f1) (Not working as intended at all)

I’ve seen a couple of posts with people having issues that may seem similar to this.
However, I’m going to elaborate as much as I can on my specific issue and what is happening now vs. what used to happen before.

Ok, so we’ve been using A* Pathfinding Project now for almost two years in our current project and even released products with the current setup. It has (for the most part) been an enjoyment working with this library and it has provided us with the needed functionality for our product.

On to the issue at hand:
I’m now in the works of porting parts of our game to iOS using Unity 5 (v5.0.1f1) and initially everything with regards to AI and pathfinding worked totally fine without upgrading the A* Pathfinding Project package. Everything was working just as it did on the PC version.

Now, a couple of days ago we realized that we had to disable JsonFx and DotNetZip (ASTAR_NO_JSON & ASTAR_NO_ZIP) to allow building versions to iOS with Bytecode stripping enabled.
Once the two optimization options were enabled and the code was recompiled, I noticed that caching of graph settings and caching graph settings at start did not work as intended any more. It was still possible to set up graph (recast) settings in the editor and scan to get a (seemingly) healthy navmesh. Caching these settings to enable loading the graph at start from cache did also seem to work fine.
However, when playing in the editor or re-opening the scene, the RecastGraph was removed entirely which left me with no navmesh (of course). Trying to re-load the graph from cache did not work as it seemed to not be able to deserialize the cached information.

So, I came to the conclusion that I (finally) needed to upgrade to the newest version of A* Pathfinding Project (v3.6).
We’ve been using v3.5 since it came out and it has been working wonderfully!
After the upgrade to v3.6, I was once again able to set up recast graph settings and save them to cache (now TextAsset files) and also load them at start perfectly. It seems the update fixed the erroneous behaviour I was seeing before.
On a side note; I had to set up the recast settings again for every scene in my project after updating. All graphs were set up with the same values that I have used before the update.

For a time, the functionality of agents and the pathfinding project itself seemed to work just fine.
I first started noticing some inconsistencies with one of my smaller scenes:
After setting up the graph and caching it, I had a navmesh that looked just fine (covering the floor of my scene). However, when I played the scene and was starting some pathing through the room, I noticed that it was like the navmesh was split into what seemed two areas, but the nodes themselves were definitely still connected to each other.
This made it so that my agents would not move further across the room than the seam that were in the middle of the room.
I tweaked the values in the recast settings a bit to make the seam go away (remember; this was not like a seam dividing two areas. Just a normal seam between a couple of nodes that would previously work just fine). This seemed to fix this behaviour in this one scene.
I wrote it off as sort of a weird thing and thought no more of it.

Then today, I was looking at one of my bigger scenes, which also had its graph recalculated and recached after updating to v3.6. For the record, this scene is about twenty times bigger that the scene I described above.
In this scene, starting a path from the player’s position to any other position on the valid navmesh now seemingly leads to an invalid path being created. The path.vectorPath contains no entries!
ABPath.cs now reports the error “Couldn’t find close nodes to the start point or the end point”. Meaning it has a start- and endpoint, but AstarPath.GetNearest() does not find a valid start- or endnode close to these points…
Unless there is something that drastically changed how one uses this library with version 3.6 compared to version 3.5, this must be a bug.
Mind you, this is the same code/functionality contained in an already released game for PC/Mac/Linux only with A* Pathfinding Project v3.5.
I’ve double-checked valid layers/tags etc, and made sure that I haven’t done any recent changes myself that would completely break the pathing functionality in this scene of the game.

From what I can see in my IsPathPossible() function, it seems like the area of the node found near the player and the area of the node found near the destination is not the same, which made me think that this was linked to the issue I discovered in the smaller scene mentioned earlier. Code below:

public bool IsPathPossible(Vector3 start, Vector3 end)
{
    var startNode = AstarPath.active.GetNearest(start).node;
    if (startNode == null)
        return false;

    var c = new NNConstraint { area = (int)startNode.Area, constrainArea = true };

    var endNode = AstarPath.active.GetNearest(end, c).node;
    if (endNode == null)
    {
        endNode = AstarPath.active.GetNearest(end).node;
        if (endNode == null)
            return false;
    }

    var possible = PathUtilities.IsPathPossible(startNode, endNode);

    if (possible)
        _lastValidNode = startNode;

    return possible;
}

The area value of “startNode” is 1. However, an “endNode” with the same area (1) cannot be found, hence it tries to find a node close to the destination Vector3 (end) that is in another area. The endnode is then found and the function returns true.
EDIT: Turning on “Areas” Path Debug Mode shows the nodes as being in the same area, even though the GetNearest search cannot find the endNode in the same area. So this is puzzling me a bit…

Optimally, I would prefer to find the endNode in an area that is the same as startNode. If this cannot be found, I would try to find the endNode in another area that is possible to create a path to. So it seems that it can create a path from start to end, but once it tries to execute the path and start walking, it fails with the error mentioned (from ABPath.cs):
“Couldn’t find close nodes to the start point or the end point”

Specifically I find that the GetNearest call in ABPath.Prepare() is not returning valid information (Line 189):

NNInfo startNNInfo 	= AstarPath.active.GetNearest (startPoint,nnConstraint, startHint);

While debugging I see that all of the data in the variable is invalid which causes it to fail with the aforementioned error.
“node”/“constrainedNode” is null.
“clampedPosition”/“constClampedPosition” is a zero vector (0, 0, 0).

Is the areas generated differently in v3.6 than in v3.5? Is this behaviour known to be different with/without the two optimizations (JsonFx/DotNetZip) enabled?
How come the endpoint is visually in the same area (literally a couple of meters away from the startpoint), but my above mentioned function cannot find a node in the same area close to the endpoint?
It very much seems like a bug in the generation of navmeshes and how areas are populated after upgrading.

Visually, the scenes and their calculated/cached navmeshes look completely similar with the same settings, but there seems to be major differences in what happens at runtime.

I hope you have some ideas on what may cause the errors I’m seeing since updating to v3.6.
I’ve been working with this package now for almost two years, so I know my way around most of the code contained.
If you want to discuss in more detail (screenshots from the editor etc.) we can do so by email.

Hoping to hear from you (Aron) or anyone else that have experienced similar issues with the newest version.

Bump!
Has anyone had similar issues upgrading from v3.5 to v3.6? I would really love some input on this.
Seems to either be working totally different or not at all as it used to in the most recent version…

UPDATE:
After some more testing, this unintended behaviour (in all scenes) seems to be consistent with when, and only when, I enable “ASTAR_NO_JSON”. Is there a bug with disabling JsonFx?
I see you’ve written a note under the optimization toggle that it “only works properly with NavmeshGraph right now”, and it’s been like that for the last few version afaik. Is the problem I’m having related to this note?
Anyhow, it’s working for me now, but does this mean that it is not possible to disable use of JsonFx when using any other graph than NavmeshGraph?

Thanks

Hi

Do you think you could try the latest beta version? I know there is a bug in the current release which causes navmeshes generated by the recast graph to sometimes contain artifacts (and I think that bug was introduced after 3.5) which is fixed in the latest beta.

That’s just some text I have forgot to update. Fixed it now in my dev version. It should say that it works for all graphs except the point graph now (but that will also likely be fixed in an upcoming beta).

Thanks for your input, Aron!

I’ll test out the beta version as soon as I can. Hopefully some time this week.
Keep up the good work, mate :wink:

1 Like

Hi again Aron,

I just tried this using the beta (v3.6.5) and it didn’t seem to make a difference, unfortunately. :frowning:
Works perfectly as long as I don’t enable “ASTAR_NO_JSON” in the Optimizations-tab.

I’m currently in the works of trying to get our game to run on iOS with IL2CPP. Currently I have yet to be able to build a version. I’m just getting IL2CPP errors. Earlier the error mentioned the Poly2Tri.dll followed by “No further information available”.
After updating to the newest Unity patch release (v5.0.2p2) the error reported is the same one, it’s just no longer mentioning Poly2Tri.dll. Only the “No further information available”.

Anyway, that was a bit off topic, but might be related I guess.
Bottom line is; “ASTAR_NO_JSON” still seems to do something odd and is not working as intended. :smile:

Hope this helps you further. Thanks!

Hi

Do you think it would be possible for you to share the project with me so I could have a look at it?

Odd thing is that I have heard people use the system on IL2CPP and it has worked well.

Hi Aron,

Thanks for your answer.
I managed to get around the errors and issues I had with IL2CPP, but it still seems as though the “ASTAR_NO_JSON” toggle is bugged in my version.
Basically, a recast graph built with ASTAR_NO_JSON toggled on seems to be generated just fine, although agents seem thoroughly confused when calculating paths. Either they just don’t get a path returned from the seeker, or they spaz around for eternity. Sometimes they seem to be able to calculate paths perfectly on half the graph, but not able to path at all on the other half.

I appreciate your help very much, Aron. Unfortunately I cannot share the project with you, though :confused:

Thanks.