Weighted path using GridGraph

I am working on an AI project where I have a 2d level and am using a GridGraph & Seeker combination to path around my world.
The world contains buildings & walls which can be moved during play. Building cannot be fully destroyed however wall can be destroyed & are removed from the GridGraph by disabling their collidor and forcing an update of their area.

What I would like to do is to not mark nodes under a wall as unpathable but instead mark them as having a higher move cost, This would then allow my Agents to asses the cost of destroying a wall to clear a path vs taking the longer path around the walls.

Is this currently possible ?



I would suggest you to put your walls in a layer ignored by the grid scan and add GUO (GraphUpdateScene) with penalties at the wall position.
Look at “Example9_Penalties”

Or if have the Pro version, you could use “Textures for penalty” (probably simplest).


I have re-factored to utilise the GraphUpdateScene from a c# script. I am now using this for all my buildings instead using the scan feature. This is giving me the fine control I want and allows me to only update what I need.

To help anyone with a similar issue a simplified version of my final solution is:

`GraphUpdateObject guo = new GraphUpdateObject();
int wallPenalty = 10000;
UpdatePath( bool walkable , bool isAWall , Collider collider )
guo .bounds = collider.bounds;

    guo .modifyWalkability = true;
    guo .updatePhysics     = false;
    if (walkable)
        guo .setWalkability = true;
        guo .addPenalty = 0;
    else if  (isAWall)
        guo .setWalkability = true;
        guo .addPenalty = wallPenalty;
        guo .setWalkability = false;
        guo .addPenalty     = 0;



calling UpdatePath will mark the area covered by the passed in Collider either as walkable , unwalkable or walkable with a high cost.

This allows the AI to path though walls but avoid it, all that is needed next is to detect this occurrence in game code and have the AI destroy the wall.