PathEngine home previous: Path objectsnext: The path away query
Contents, Programmers Guide, Example Projects, Tutorials, Tutorial 3, The shortest path query

The shortest path query

This is the fundamental pathfinding query.
This query returns the shortest set of movement sections taking an agent from a start position to a specified target position, if one exists.

The query is provided as iAgent::findShortestPathTo() and as iMesh::findShortestPath().
The iMesh version doesn't require an agent.
The iAgent version finds the shortest path from an agent's current position to a specified target.

Calling the query is pretty simple:

if(testbed->getLeftMouseState())
{
// path towards position under mouse
	path = nullptr;
	cPosition target=testbed->positionAtMouse();
	if(target.cell!=-1)
		path = agent->findShortestPathTo(context, target);
}

Note that passing in our collision context means that the query will automatically take account of any obstacles added to that context.


Documentation for PathEngine release 6.04 - Copyright © 2002-2024 PathEnginenext: The path away query