GraphUpdateObject and Tags issue

Hi, Im having an issue with GUOs and Tags. Heres my code:

My GUO class

public class NoSpawnZoneGUO : GraphUpdateObject { public override void Apply(GraphNode node) { //Debug.LogError(node.Tag); node.Tag = 1; } }

My constraint

NNConstraint constraint = new NNConstraint
    {
      constrainTags = true,
      tags = 1
    };

My GUO code

var guo = new NoSpawnZoneGUO
{
 updatePhysics = false,
 bounds = new Bounds(p.transform.position, new Vector3(5, 5, 5)),
  requiresFloodFill = false
 };
 AstarPath.active.UpdateGraphs(guo);
 AstarPath.active.FlushGraphUpdates();

My search

spawnPos = AstarPath.active.GetNearest(camPos, constraint).clampedPosition;

What I have found is that setting the tag to 1 works perfectly, but setting it to anything else will always result in spawnPos returning Vector3.zero.
Is there anything obvious that I`m doing wrong?

regards
Brad

Hi

Note that the tags field is a bitmask so to make it possible to walk on tag 1 you would set it to “1 << 1”, to make it possible to walk on tag 5, 7 and 14 you would set it to “1 << 5 | 1 << 7 | 1 << 14”.

The default value for the field is “-1” which in binary is represented as 111111… i.e all bits are ones so all tags are enabled.

See also https://en.wikipedia.org/wiki/Mask_(computing)

Thanks for the response. I did try and bit shift as well with the same result. It’s not that I want the nodes to be not walkable, I just need them to be excluded from a search.

EDIT: Ok figured it out

GUO should have been this :

public class NoSpawnZoneGUO : GraphUpdateObject
{
  public override void Apply(GraphNode node)
  {
    //Debug.LogError(node.Tag);
    node.Tag = 1 << 2;
  }
}

and constraint like this :

_constraint = new NNConstraint
    {
      constrainTags = true,
      tags = 1 & ~2
    };

to exclude Tag 2 from the search.