Tags still not working in 4.3?

Hi,

I’m struggling to get tags working with recast graph. Having read some other threads, there’s a known issue with this in 4.2 which I was using with Unity 2019.4 (LTS). I have tried updating to 2020.1 and using the A* 4.3 beta but I’m still having the same issue where my character is walking over non-traversable areas.

I have a doorway that I don’t want my player to walk through but the AI can, so I have used GraphUpdateScene to use a tag called “AI Only”. My player character has this tag unchecked in Traversable. Also, when I scan the graph and set graph coloring to Tags I can see it’s correctly tagged the area in the doorway so the player shouldn’t be able to walk through it. But the character walks right through it. Turning off the RayCast Modifier doesn’t make any difference.

Is this still a bug or are there any other rules I should follow to get this working with a recast graph??

Thanks!

Looking for help here. Anyone else having this issue? Looks like it was meant to be fixed in 4.3 but still can’t get it to work.

Hi

Does the example scene called “Penalties” work correctly for you?
Which movement script are you using?
What are you seeker -> Start End Modifier settings?

Hey!

To answer your questions:

  1. Yes, Penalties example works. I think the big difference is that’s using a Grid Graph not a recast graph?
  2. I’m using AIPath movement script, just like the Penalties example. Settings look similar.
  3. I’m using “Closest On Node Surface” for both my start and end modifiers in my Seeker Component. I’ve noticed the Penalties example uses “Original” for start and “Node Center” for End with Graph Raycasting turned on. I tried these settings but it didn’t make a difference.

I also tried just creating a new restricted area - a simple cube shape on some flat ground (which also correctly shows up as tagged) and the player still walks on it just fine even though it’s tagged as AI Only. Thoughts?

And thanks in advance for your help!

I have run into a similar problem. I am using the Pro version and have set up a Flood script. It’s completely ignoring the penalties and traversability. I dropped my bots into the “PenaltiesExample” and they just walk across it as if it isn’t there. I feel like I need to incorporate something into the script but I can’t find an example of what I need to do.

In Start I set up the pathing:
_floodPath = FloodPath.Construct(_target.transform.position, null);
AstarPath.StartPath(_floodPath);
_floodPath.BlockUntilCalculated();
FloodPathTracer fpathTrace = FloodPathTracer.Construct(seeker.transform.position, _floodPath, null);
seeker.StartPath(fpathTrace, OnPathComplete);

I have a function called RecalculatePath that essentially does the same thing. This will be for a TD style game and so I need to have the AI react when a new tower is placed. That line is commented out now since I am simply testing the AI getting from the start to the target, which currently is stationary.

My Update function is:

if (Time.time > lastRepath + repathRate && seeker.IsDone())
{
lastRepath = Time.time;
//RecalculatePath();
}

if (path == null)
{
return;
}

reachedEndOfPath = false;

float distanceToWaypoint;
while (true)
{
distanceToWaypoint = Vector3.Distance(transform.position, path.vectorPath[currentWaypoint]);
if (distanceToWaypoint < nextWaypointDistance)
{
if (currentWaypoint + 1 < path.vectorPath.Count)
{
currentWaypoint++;
}
else
{
reachedEndOfPath = true;
break;
}
}
else
{
break;
}
}

var speedFactor = reachedEndOfPath ? Mathf.Sqrt(distanceToWaypoint / nextWaypointDistance) : 1f;

Vector3 dir = (path.vectorPath[currentWaypoint] - transform.position).normalized;
Vector3 velocity = dir * speed * speedFactor;

controller.SimpleMove(velocity);

I have 2 AIs and they match the penalties set up in the example: a penalty of 300 for one of them and non-traversible for the other. It makes no difference. I am sure I am missing incorporating the tags, I just need to figure out how.

metaldonut, I think you and I may be in a similar boat here. Not sure if this helps you. I’m still trying to figure it out.

I figured it out for my code. This has been a few days in the making, but this worked for me. I found another post (linked below) and used the code to set up the penalties while calculating the initial FloodPath.

I modified Start() to this and it worked:

_floodPath = FloodPath.Construct(_target.transform.position, null);
_floodPath.nnConstraint.graphMask = seeker.graphMask;
_floodPath.tagPenalties = seeker.tagPenalties;
_floodPath.enabledTags = seeker.traversableTags;
AstarPath.StartPath(_floodPath);
… (rest of the code, I only modified the first part)

I hope this helps!

Link to the post that helped me:

@Derezzed - Thanks so much for sharing. I’m just using the AIPath script which is the same as the penalities example. I looked at it and it looks to be using similar code (i.e. pulling the seeker.traversableTags into the path.enabledTags).

@aron_granberg - Any thoughts here based on my prior responses? I still can’t see why this isn’t working in my scene vs the penalties scene other than I’m using recast instead of grid. Could that be the issue?

@aron_granberg I just tried converting my graph from a recast to grid graph to test and the tags/traversible areas are working correctly. Therefore, I think the issue is still with recast graphs not working with tags.

Unfortunately, I need to use a recast graph for my scene. Any thoughts on a fix? Thx

Hi

@metaldonut
Sorry for the late reply.
I cannot replicate this, would it be possible for you to share a small example scene that shows the issue?

For sure - Do you have a support email I can send this to?

You can send it using a forum PM.

1 Like

Hi

The issue turned out to be that you are using a navmesh cut. Navmesh cuts inherently do not work well with tags because they can change the geometry of the graph arbitrarily, so there is no obvious “good” way to preserve tags once navmesh cuts come into play.
One can notice this because once the navmesh cut is activated the ‘Tags’ debug mode no longer shows the other nodes as having a different tag.

When looking at your scene you seem to have a very grid-like recast graph (the tile size is tiny). I would recommend that you use a grid graph (or layered grid graph) instead which will work a lot better with tags. You can use the ‘Dynamic Grid Obstacle’ component instead of the navmesh cut component (though you will also need to change your obstacle to have a layer that is treated as an obstacle by the grid graph).

Ok, thanks, I’ll try making it work with a layered grid as suggested.