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
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.