Manual pathfinding result vectorPath has odd values

I’m trying to move some path finding from using the Seeker to manually calling the system. But for some reason it’s returning odd values in the vectorPath. Here’s my code that works fine with the Seeker component:

void CalculatePath()
{
	//m_seeker.StartPath(m_trans.position, m_targetPosition, OnPathCompleted, AIGraphMask);
	ABPath currentSearchPath = ABPath.Construct(m_trans.position, m_targetPosition, null);

	currentSearchPath.callback += OnPathCompleted;

	currentSearchPath.nnConstraint.graphMask = AIGraphMask;

	foreach (MonoModifier monoModifier in m_modifiers)
	{
		monoModifier.PreProcess(currentSearchPath);
	}

	AstarPath.StartPath(currentSearchPath);
}

void OnPathCompleted(Path p)
{
	if (p.error)
	{
		...
		return;
	}

	foreach (MonoModifier monoModifier in m_modifiers)
	{
		monoModifier.Apply(p);
	}

	m_currentWaypointIndex = 0;
	CurrentPath = p;
}

and here’s the output of the call as you can see the vectorPath returns points that doesn’t match with the endPoint.

Hi

You are missing one modifier. The StartEndModifier. It’s part of the seeker because you pretty much always want it. Without it, the vectorPath will just be the sequence of node centers that the path traversed.

You can add it using

// Cache this somewhere
var m = new StartEndModifier();

m.Apply(p);

See also Documentation

1 Like

Hello,

Thanks that was exactly what I was missing.

1 Like