Support Forum

AILerp getting stuck on point graph after GraphUpdateScene is applied

Ive been encountering a bit of an issue and have been unable to fix it but have narrowed down the issue as much as I could. Short version is that the AILerp is freezing when trying to enter a point grid node after I have applied a GraphUpdateScene to the area around the node.

In more detail it’s a tower defense game with placed towers changing the tag of the graph to let enemies know they should go around. These towers can also be destroyed and when they do the tag is changed back to the default. I have an agent using an AILerp component on the point graph which acts as a leader for several RichAI agents who move in a formation on a recast graph. Each tile where towers can be placed has a GraphUpdateScene which is applied to update the tag of the ground on the recast graph when a tower is placed on that spot. When the tower is destroyed the GraphUpdateScene is changed to revert the tag to the default and then applied again. Once this has been done and an agent tries to move through the newly cleared tile it just stops at the edge of the tile or goes part way in before suddenly jumping off the connection and freezing.

Here is the code being called when a tower is placed and when removed. If I comment out the line setting the tag the AILerp agent works as expected with no problems but when the line is active I have the problem mentioned above.

public void AddedTower()
{
    graphUpdateScene.modifyTag = true;
    graphUpdateScene.setTag = 1;
    graphUpdateScene.Apply();

    //Update the point graph for the formations
    if (AstarPath.active.data.pointGraph != null)
    {
        var pointNode = AstarPath.active.data.pointGraph.GetNearest(transform.position).node as 
                                  PointNode;
        pointNode.Tag = 1;
    }
}

public void RemovedTower()
{
    graphUpdateScene.modifyTag = true;
    graphUpdateScene.setTag = 0;
    graphUpdateScene.Apply();

    //Update the point graph for the formations
    if (AstarPath.active.data.pointGraph != null)
    {
        var pointNode = AstarPath.active.data.pointGraph.GetNearest(transform.position).node as 
                                  PointNode;
        pointNode.Tag = 0;
    }
}

And here are the settings for my AILerp agent
AILerp

Hopefully its just something simple I’m overlooking. Any help would be appreciated and let me know if there is any more info that would be useful.

So you mean that the node is completely surrounded by a tag it cannot traverse?

What is the result that you want?

Thanks for the response. Let me try to clarify…

The recast graph is set as having a region of a high cost but still traversable tag around the towers. Maybe I am misunderstanding the GraphUpdateScenes but I thought they didn’t/weren’t supposed to affect the point graphs. At least as far as I can tell they aren’t when I’m looking it with graph coloring set to tags. The recast shows the new color but the point graph nodes show no change.

What seems to be happening is that when I do set and apply the tag on the graph update scene it is breaking the node on the point graph in some way. The enemies using the recast graph work fine in that area but the AILerp unit trying to traverse through the point graph node there will do one of a few things.

-Get suck mid way between the previous node and the problem node when trying to move to it.
-Reach the problem node but then suddenly get thrown to a random spot around it, usually up above the graph itself.
-Reach the problem node and continue on but partway to the next node will freeze in place.

When any of these happen the AIlerp debug states it reached the end of the path. Before the AILerp reaches the node though, if I have the seeker component set to draw gizmos it correctly shows the green intended path passing right through the problem node and continuing to the destination. So everything seems fine up until the AILerp actually tries to pass through the problem node.

There are also multiple other paths to take around the node if it was just set as being unwalkable or a high cost.

Here is another picture of the seeker component with the tags shown. The ground is being toggled between The basic ground tag and the tower tag, both of which are set as traversable.
Capture

To be specific about the result I want, I just want the AILerp to pass through the node normally like it does with all the other ones. It works fine whenever I comment out the line setting the graphUpdateScene to set the tag to 0 or 1 but that is needed to set the tags on the recast graph nodes properly. I tried a lot of stuff to get it working but have had no luck so far.

I can try to take a video of the problem occurring if you think that would help.