Not getting GraphUpdateObject to work right

I have a scene that has an island in the middle with water all around it. I want to make the water tagged as unwalkable so AIs avoid it. I also want to be able to assign weights to water traversal (and swimming) later. In a simpler scene I was at one time working, but I have missed something in the more complex scene (with actual terrain).

I am using a recast graph to create the navmesh. Here are the settings:

I have tried using a GraphUpdateScene object and given it the bounds of the whole scene with the y value locked to sea level. It looks like this:

When I do the graph scan, everything seems in order. Normal pathing works great.

Here are my A* settings:

And my AI settings:

I have tried scripting it, but with no success. The following halts all AIs:

                GraphUpdateObject guo = new GraphUpdateObject(water.GetComponentInChildren().bounds);
                guo.setTag = 1;
                guo.modifyTag = true;
                guo.setWalkability = false;
                AstarPath.active.UpdateGraphs(guo);

I found a post about extending the GUO object, but It just processed a lot and never gave any indication it completed or worked.

using UnityEngine;
using Pathfinding;

namespace Assets._Code.AI
{
    public class WaterGUO : GraphUpdateObject
    {
        public float ylimit = 0;
        public override void Apply(GraphNode node)
        {
            if (((Vector3)node.position).y <= ylimit)
            {
                node.Tag = 1; //Set to use tag 1 (default tag is tag 0)
            }
        }
    }
}

Used that class with:

            WaterGUO guo = new WaterGUO();
            guo.bounds = water[0].GetComponentInChildren().bounds;
            guo.ylimit = 50;
            AstarPath.active.UpdateGraphs(guo);

I feel like I am going in circles. If the AIs move, they still go right into the water.

Any ideas are appreciated as it gets me thinking of other possibilities.

I added some debug to my script (with the first snippet of code). I got all of the nodes and printed out their tag and walkability. For all nodes it is tag 0 and walkability True. I added AstarPath.active.FlushGraphUpdates() which take several minutes to run, but doesn’t change the node output. After the flush, there are no queued updates, and there is an update queued when I add the GUO to AstarPath.active.UpdateGraphs(guo).

Help, please. I am getting frustrated because I can’t see what I am doing wrong.

Hi

You’ve got ‘Update Physics’ enabled on the GraphUpdateScene component. This will make it recalculate all tiles which it touches instead of just changing the existing nodes (see http://arongranberg.com/astar/docs/graph-updates.php). You probably want to disable that.

That seems to be working.

Thank you very much!!!

1 Like