Am I using tags constraint correctly?

Hello Aron,

Am I using the tags correctly? My character computes paths that seems to disregard tags.
They lead straight into forbidden areas, when I wish to reach an enemy located inside forbidden area.
I would expect a path to terminate at the closest traversable point, without continuing into forbidden regions.
Here is how I compute paths (manually):

   _dash_path = ABPath.Construct( transform.position,  target.navAgentComponent.position );
   _dash_path.nnConstraint.constrainTags = true;
   _dash_path.nnConstraint.tags = 1<<4;  //only 4th tag is to be traversable

   AstarPath.StartPath(_dash_path, true );//<-- true: push to front of the queue
   _navAgentSeeker.PostProcess( _dash_path );
   _navAgent.SetPath( _dash_path );   

Afterwards, I move along path similar to this:

//compute how AI wants to move:
_navAgent.MovementUpdate( Time.deltaTime, out nextPos, out nextRot );

//... my own adjustment to nextPos  ...

_navAgent.FinalizeMovement( nextPos, nextRot); 

NavAgent is AIPath.cs



While setting the nnConstraint.tags will make it only pick that tag when searching for the start and end node for the path, it will not prevent the path from visiting other tags during the search. For this you should set path.enabledTags.

_dash_path.enabledTags = 1 << 4;
1 Like