PathEngine home previous: iAgent::canPathfind()next: iAgent::findPathAway()
Contents, API Reference, Interfaces, iAgent, findClosestUnobstructedPosition



Finds the closest unobstructed position, if one exists within a specified region around the agent's position.


cPosition findClosestUnobstructedPosition(const iCollisionContext* context, int32_t maximumDistance) const;


context The state of dynamic collision that will apply for this query.
An empty context can be specified by passing nullptr for this argument.
Note that the agent is not considered to obstruct itself even if included in this context.
maximumDistance This parameter controls the size of the region within which to search for an unobstructed position.
Must be greater than zero.


Requires that the agent is moveable and that collision preprocess has been generated on the agent's mesh for the agent's collision shape.

Return Value

If an unobstructed point exists in the specified region then a cPosition is returned for that position.
Otherwise an explicitly invalid cPosition is returned, i.e. a position with cell set to -1.


The region searched is an axis aligned rectangle defined by the agent's current position and maximumDistance, as follows:

x >= position.x - maximumDistance
x <= position.x + maximumDistance
y >= position.y - maximumDistance
y <= position.y + maximumDistance

Only positions reachable through the mesh within this region are searched. This prevents points on completely unconnected layers of overlapping geometry being returned.

See Also


C# Mapping

PathEngine.Position findClosestUnobstructedPosition(CollisionContext context, int maximumDistance);

Java Mapping

Position findClosestUnobstructedPosition(CollisionContext context, int maximumDistance);

Documentation for PathEngine release 6.03 - Copyright © 2002-2021 PathEnginenext: iAgent::findPathAway()