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.



