Perimeter Of Updated Area Showing Incorrect Nav Penalty

Hi,

I’m painting my grid terrain by doing a GraphUpdateObject with a bounds:

image

I have debugged and confirmed the bounds does not contain the green nodes surrounding the red zone and have also confirmed that I am not setting those values by setting every node to max penalty hence the red.

Here is the console debug output i added that shows the nav penalty for every edited node in the update:

image

I can’t see any reason for why those are green. If I update the entire terrain then it recalculates those nodes to be their correct value. Is it anything to do with recalculating links?

Any help would be appreciated,

Thanks

I’m debugging AStar now and first indications are that it’s caused somewhere here:

RecalculateCell() is called for the perimeter cells but the graph update object is not. It appears to be because

image

Is altering the rect.

Hope that helps,

On further investigation it’s because GraphUpdateObject resetPenaltyOnPhysics is default to true. This is not a parameter i’d considered and it seems odd that the default behaviour is as i’ve discovered it here :).

It doesn’t feel like this should be affecting a larger bounds than i’ve asked to be edited.

Hi

Yeah, the GraphUpdateObject API is kinda due for a redesign to make things more easily interpreted.

What happens here is that the script needs to recalculate a few more nodes from scratch than just those included in your bounding box. This can happen if you for example are using the erosion setting, or if you have a collision testing diameter greater than 1. All those nodes will be recalculated from scratch. As if the graph had just been scanned. This also implies their penalty will be reset to the default value.

You can prevent that reset by setting resetPenaltyOnPhysics to false.

If you just want to set a penalty I’d recommend setting guo.updatePhysics = false to avoid recalculating the nodes from scratch.

1 Like