modifyTag and setTag not working on a GraphUpdateObject

Hello,

I’m running into some issues updating nodes tags on my grid graph. For context the game is a city builder, and I am trying to change a tag when a path is placed.

I initially tried by using a GraphUpdateScene object, this works to update the node penalties (ground has penalty of 25k by default), but does not change the tag. I then tried the following code:

        // located in start method of a script placed on the path object

        GraphUpdateObject guo = new GraphUpdateObject(GetComponent<BoxCollider>().bounds);

        guo.modifyTag = true;
        guo.setTag = 1; // basic ground is tag 0, path is tag 1

        
        guo.addPenalty = 0;

        AstarPath.active.UpdateGraphs(guo);
        AstarPath.active.Scan();

and had the same result, updated penalties but no updated tags. I’ve made sure that the layer my path object is in is in the layer mask for height testing, and that the bounds of the path are set up to be large enough. Any ideas?

Cheers

After a scan with graph colouring set to penalties
Screen Shot 2023-05-15 at 12.03.42 PM

Same with graph colouring set to tags

Here is the setup used for my initial attempt with the GraphUpdateScene, couldn’t attach it to initial post due to 2 media items limit.

Screen Shot 2023-05-15 at 12.00.11 PM

Hi

You should not scan the graphs after the update. That will make the graph be recalculated from scratch and all your edits will disappear. Remove the Scan call and just leave UpdateGraphs.

Regardless, though. I would recommend that you set guo.updatePhysics=false. If you are doing other graph updates with that flag, make sure to disable it for those as well. Using updatePhysics will reset the tags in the region before the update.