Hi,
I have some button in the level that changes the layout of the level. I precomputed the navmeshes for both states (on/off) and saved them to different files. There are also links (NodeLink2) that get toggled when the button state changes. If I use only AstarPath.active.data.DeserializeGraphs(navmeshData.bytes); , AstarPath.OnGraphsUpdated is not triggered and the AI doesn’t consider the links at all (as if they’re not there). I tried to forcefully update all the graph after deserializing the file but am getting some exceptions regarding PointNode. How should I tackle this?
protected void OnEnable()
{
if (loadOnEnable)
Load();
}
public void Load()
{
if (!navmeshData)
return;
AstarPath.active.data.DeserializeGraphs(navmeshData.bytes);
AstarPath.active.UpdateGraphs(new Bounds(
center: AstarPath.active.data.recastGraph.forcedBoundsCenter,
size: AstarPath.active.data.recastGraph.forcedBoundsSize
));
}
exception
NullReferenceException: Object reference not set to an instance of an object
Pathfinding.PointNode.AddConnection (Pathfinding.GraphNode node, System.UInt32 cost) (at Assets/AstarPathfindingProject/Generators/NodeClasses/PointNode.cs:142)
Pathfinding.NodeLink2.Apply (System.Boolean forceNewCheck) (at Assets/AstarPathfindingProject/Core/Misc/NodeLink2.cs:196)
Pathfinding.NodeLink2.OnGraphsPostUpdate () (at Assets/AstarPathfindingProject/Core/Misc/NodeLink2.cs:131)
Pathfinding.GraphModifier.TriggerEvent (Pathfinding.GraphModifier+EventType type) (at Assets/AstarPathfindingProject/Core/Misc/GraphModifier.cs:80)
Pathfinding.GraphUpdateProcessor.ProcessGraphUpdates (System.Boolean force) (at Assets/AstarPathfindingProject/Core/Misc/GraphUpdateProcessor.cs:190)
Pathfinding.WorkItemProcessor.ProcessWorkItems (System.Boolean force) (at Assets/AstarPathfindingProject/Core/Misc/WorkItemProcessor.cs:306)
AstarPath.PerformBlockingActions (System.Boolean force) (at Assets/AstarPathfindingProject/Core/AstarPath.cs:860)
AstarPath.Update () (at Assets/AstarPathfindingProject/Core/AstarPath.cs:843)