This page is a work in progress and could be pending updates.

Navigation World Subsystem

The UQuantumNavigationSubsystem is used to manage the building, querying and storing of navmeshes.
To access it call GetWorld()->GetSubsystem<UQuantumNavigationSubsystem>().

You can manually invoke the navmesh building by calling Build() on it.
If a map is loaded with an existing navmesh or a navmesh was built for a map the GetNavMesh() method can be used to return a corium::dtNavMesh*.
The GetNavMeshQuery() method will return a corium::dtNavMeshQuery*. The navmesh query can be used to run queries on the navmesh.

The internal data structures assume that the y-axis is the up axis, all query methods on the UQuantumNavigationSubsystem are swapping the y and z axis for all function arguments as well as for all out parameters.
If the query object is used directly then this has to be done manually.

Pathfinding

There are 2 ways to find a path, FindFollowPath will return a smooth path with many waypoints in equal intervals and FindStraightPath with one waypoint per navmesh polygon.

FindFollowPath

The FindFollowPath methods takes in a std::vector<FCVector3> reference which will be filled with the waypoints
as well as an corium::FindFollowPathOptions reference containing all parameters for the navmesh query.

c++

static void FindFollowPath(std::vector<FCVector3>& outWaypoints, corium::FindFollowPathOptions& options);

c++

struct FindFollowPathOptions {
    // Start position of the path
    FCVector3 startPosition;
    
    // End position of the path
    FCVector3 endPosition;
    
    // The navmesh that will be searched for a path and its query object
    dtNavMesh* navMesh;
    dtNavMeshQuery* navMeshQuery;

    // The extents around the start/end position in which a navmesh polygon will be searched
    FCVector3 polyPickExt;
    
    // Navmesh filter to set costs/path restrictions
    dtQueryFilter filter;

    // Maximum number of waypoints that will be returned
    int maxWaypoints;

    // Maximum number of polygons that will be searched
    int maxPolys;
}

FindStraightPath

The FindStraightPath methods takes in a std::vector<FCVector3> reference which will be filled with the waypoints,
a std::vector<unsigned char> pointer that will be filled with the flags for each waypoint if not null,
a std::vector<corium::dtPolyRef> pointer that will be filled with the polygon references for each waypoint if not null,
as well as an corium::FindStraightPathOptions reference containing all parameters for the navmesh query.

c++

static void FindStraightPath(std::vector<FCVector3>& outWaypoints, std::vector<unsigned char>* outFlags, std::vector<corium::dtPolyRef>* outPolyRefs, corium::FindStraightPathOptions& options);

c++

struct FindStraightPathOptions {
    // Start position of the path
    FCVector3 startPosition;
    
    // End position of the path
    FCVector3 endPosition;
    
    // The navmesh query that will be searched for a path
    dtNavMeshQuery* navMeshQuery;

    // The extents around the start/end position in which a navmesh polygon will be searched
    FCVector3 polyPickExt;
    
    // Navmesh filter to set costs/path restrictions
    dtQueryFilter filter;

    // Maximum number of waypoints that will be returned
    int maxWaypoints;

    // If only area crossings are returned or all crossings
    dtStraightPathOptions pathOptions;
}

Other Navmesh Queries

Raycast

The Raycast method should be used for quick and short distance checks.
It returns the hit parameter, position, normal and polygon path to the hit position.
If the hit parameter returns a high value (MathConsts::MAX_VALUE) then the ray has hit the end position.
In that case the path is a valid path to the end position.
If the hit parameter is zero the start position is on the same wall that was hit.
If the parameter is between 0 and 1 then the distance to the hit location is distanceToHitBorder = distanceToEndPosition * t.

This method ignores the z-axis and checks for collisions only on a 2D plane.

FindDistanceToWall

Returns the distance to the closest wall and the position and normal. If the distance equals the search radius no wall was found.

FindPolysInCircle

Finds all polygons inside a circle. The order of the polygons is from least to highest cost.

FindPolysInLocalNeighborhood

Similiar to FindPolysInCircle but optimized for small search radius checks.

FindPolysInShape

Finds all polygons inside a shape which can be defined by vertices. The shape has to be convex.

Back to top