Recast graph loses penalty after NavmeshCut


#1

Hi,

My recast graph loses its penalties applied through an GraphUpdateScene after an object cuts into the graph. What would be the correct way to re-apply the penalties after a cut.
I found the OnEnableCallback on the NavmeshClipper however this is a private event.


#2

Hi

Yes, unfortunately there is no way to keep penalties after a navmesh cut as the graph can have changed in arbitrary ways.

I would recommend that you use tags (because applying a tag multiple times to the same region is ok, in contrast to penalties which will accumulate). To get an event when graph updates are done you can make a script inherit from the GraphModifier class, and then override the OnGraphsPostUpdate method.

class MyType : GraphModifier {
    public override void OnGraphsPostUpdate () {
    }
}

#3

Hey,

Reapplying the tags in OnGraphsPostUpdate invoke OnGraphsPostUpdate causing an infinite loop.


#4

Oh, right… I suppose you could call (AstarPath.data.recastGraph as IUpdateableGraph).UpdateArea(guo) directly, that will not cause the callback to be called. And since you are only updating penalties it should be fine.