Point outside of mesh

Im running a code that feeds a number of points to the pathfinding algo and some of these points end up outside the limits of the level which is bordered by walls layered under obstacles in a recast graph.

I have double checked the seeker and it should snap to closest point but instead the agent is stuck on the wall with a green line pointing outside of the wall.

The path is made using seeker.setpath and is not returning an error so I am at a loss as to what to do

Hi

Could you post the exact code you are using?

You replied instantly but I fell asleep :smiley:

public override void Update()
        {
            if( m_Data.RichPathfinding.hasPath )
            {
                if( m_Data.RichPathfinding.remainingDistance <= m_Data.RichPathfinding.endReachedDistance )
                {

This is what I use to walk until I reach the point

CalculateNextStepInPathAsync()
{
//logic for pos
 m_Data.Seeker.StartPath( p_Intelligence.transform.position, pos, Callback );
}

private void Callback( Path p )
        {
            if( p.error )
            {
                m_Index--;
                CalculateNextStepInPathAsync();
            }
            else
            {
                //m_Data.RichPathfinding.SetPath( p );
            }
        }

and this is what I use to calculate the point, the else is commented out since I use the seeker and it listens to the StartPath automatically.

RichPathfinding is a reference to RichAI

level
outside these walls he tries to go

@aron_granberg it feels like it tries to go there as part of going “off-mesh” for a bit. Still not sure how to fix it

Hi

Can you post a screenshot of the green path in the scene view when it tries to go off mesh?

Sure, give me a sec, I’ll do it now

Basically I have this spiral and it’s trying to go to the first dot at the top left

Hi

To me it looks like the path stops right at the border of the navmesh. That looks like the closest point it can reach which is exactly where it should try to go.

But why is it trying to continue off of it? Shouldn’t that part say something like “I’ve reached the max point I can” so I can tell it what to do next.

The agent will continue to the edge of the navmesh and it should stop there.
The ai.reachedEndOfPath property will return true and ai.reachedDestination will return false (as it couldn’t actually reach the destination given).

1 Like

OK, I’ll change the code to use reachedEndOfPath and it ll probably work

Hmmm it works but not all the time, quite a bit of the time is false

Are you sure the character is not being stopped due to its collider or something?

1 Like

I’ll double check that too. Thanks! I guess if I do his radius as large as his collider then I won’t have any issues

1 Like