Seeker Walking on un-walkable nodes


The seeker seems to be walking through un-walkable nodes near obstacles freely. I’ve checked all sorts of things like max nearest node distance, seeker settings, path constraints and nothing makes a difference. below is the code for the constraints & my seeker settings.

Code for the path constraint.

    //Alternative way of requesting the path
    ABPath p = ABPath.Construct (GetFeetPosition(), SearchPath_targetPosition, null);
    NNConstraint pathConstraint = NNConstraint.Default;
   
    pathConstraint.constrainWalkability = true;
    pathConstraint.walkable = true;

    p.nnConstraint = pathConstraint;

    if(SearchPath_targetPosition != Vector3.zero)
    {
        seeker.StartPath(p, null, 1 << entityAllowedGraphMask);
    }

Code for the graph constraint.

graphConstraint = NNConstraint.None;
graphConstraint.walkable = true;
graphConstraint.constrainWalkability = true;
graphConstraint.graphMask = (int)(Mathf.Pow(2, AstarPath.active.graphs.Length) - 1);

Code for wandering

private Vector3 Target()
{
Vector3 direction = transform.forward + Random.insideUnitSphere * wanderRate.Value;
Vector3 wanderPoint = transform.position + direction.normalized * wanderDistance.Value;
wanderPoint.y = 0f;

        return wanderPoint;
    }

A* Settings

Seeker Settings

AIPath settings

Hi

It looks like you have added a SimpleSmoothModifier to the character GameObject.
That will smooth out the path, but if you smooth it out too aggressively it may intersect obstacles. I would suggest that you tweak the settings on the SimpleSmoothModifier component to reduce the amount of smoothing.

Hello, the AI seems to move through un-walkable areas still. how does this relate to the smoothing?

Hi

You are using multiple graphs, so it is hard to see which nodes are unwalkable in the graph that the character is actually traversing.

so the AI is walking on the wrong graph you think?

if it is how do you recommend we solve this problem? i’d like the AI to be able to traverse only the graph with obstacles.

graphConstraint.graphMask = (int)(Mathf.Pow(2, AstarPath.active.graphs.Length) - 1);

this is where I set the graph mask.

First I think you should try adjusting the SimpleSmoothModifier settings. Try disabling it first.

just did, nothing changed.

Ok. From what I can see it seems to use the graph without at least some of those obstacles. It looks like it follows a valid path on the graph it uses.
You should focus on this line

seeker.StartPath(p, null, 1 << entityAllowedGraphMask);

That is what sets which graphs it can use.
What is ‘entityAllowedGraphMask’ set to?

graphConstraint.graphMask = (int)(Mathf.Pow(2, AstarPath.active.graphs.Length) - 1);

    if (spawnPoint as POISpawner == true)
    {
        graphConstraint.graphMask &= ~(1 << 0);
    }

    GraphNode graphNode = AstarPath.active.GetNearest(transform.position, graphConstraint).node;

    if (graphNode != null)
    {
        Debug.Log("Valid Graph Node for wandering......"+gameObject.name);
        entityAllowedGraphMask = (int)(graphNode.GraphIndex);
    }
    else
    {
        Debug.Log("Invalid Graph node for wandering...");
        entityAllowedGraphMask = 0;
    }

Ok, and is the last graph the graph that you actually want to use?
You can switch on and off the display of different graphs by clicking on the ‘eye’ icon next to the graph name.

we have 2 grids:

one is procedural and one Is static to a village.
when the player enters the village his graph (the procedural one) is also there.
are the obstacles detected on the player grid graph? or could the AI be moving on the player’s graphs hence not detecting the obstacles of the village graph are not detected?

I would like to know which graph the AI is using and if u think there might be other causes to this problem

we are using your procedural grid mover script.

what I want to use is the graph that has the obstacles, which is the village graph.

Hi

The procedural grid mover will use the first grid graph (unless you have made any modifications).
There seem to be unwalkable nodes on both graphs.
Try calling

Debug.Log(entityAllowedGraphMask);

Right before calling seeker.StartPath.
Are you calling seeker.StartPath anywhere else in the code?

Do you think you could post a screenshot of the list of all graphs? (preferably one by one with the scene view showing only that graph (use the eye icon to hide and show them).

it appears the graph the graph mask keeps changing for some reason.

http://imgur.com/rcyhNXS

From your screenshot it doesn’t seem like this line is being triggered

Debug.Log("Valid Graph Node for wandering......"+gameObject.name);

Is entityAllowedGraphMask being set somewhere else?


Also, this line

if (spawnPoint as POISpawner == true)

will never become true. You should instead do

if (spawnPoint is POISpawner)