Physics Check & Recalculate Cell


I’ve hit another issue with this code path that I can’t see a work around to. The scenario is I have water in my game that needs to be marked unnavigable. It is not it’s own mesh and so AStar can’t differentiate between land and water.


The sequence of events is:

  1. User clicks to paint terrain in the water.

  2. GraphUpdateObject is configured like so:
    MyGUO guo = new MyGUO();
    guo.bounds = b;
    guo.updatePhysics = true;
    guo.updateErosion = false;
    guo.resetPenaltyOnPhysics = false;

  3. The bounds encapsulates the central 4x4 cells.

  4. My UpdateGraphNodeForCell function is called for each of those 4x4 cells:

  5. AStar casts rays and evaluates that the outside ring of cells does not have any obstructions and so is walkable.

  6. My UpdateGraphNodeForCell function is not called for those and so i can’t override it.

Why is this done in GridGenerator?

That is expanding the rect for the eventual casts which causes my walkable values to be overwritten.



It is done because if you for example add a collider with bounding box B to the scene and update the graph with that bounding box, then nodes up to Grid Graph -> Collision Testing -> Diameter / 2 world units away from B may be affected (or more if erosion is also used).
If you want to disable physics completely then you just disable collision testing in the grid graph settings.

Thanks for the reply.

I am allowing astar to detect obstacles that are blocking navigation, such as trees and rocks. It sounds like i’ll need to do that myself if the solution here is to turn off the physics check in astar.

One other thought is that a callback for the raycast that astar performs would be useful. If astar said to me “this thing has been hit with the physics check, is this a blocking object?” then i could check the terrain for whether the intersect point is water/land.

(alternatively if you are up for something lower level you can use the beta and implement a custom grid graph rule:

Not sure if you saw my reply above, was i correct in that i’d have to do the casts myself?

Yes, you will need to do that.

Ok thanks for the help.