Navigation
API > API/Runtime > API/Runtime/Navmesh
Provides local steering behaviors for a group of agents.
This is the core class of the Crowd module. See the Crowd documentation for a summary of the crowd features.
A common method for setting up the crowd is as follows:
Allocate the crowd using dtAllocCrowd.
Initialize the crowd using init().
Set the avoidance configurations using setObstacleAvoidanceParams().
Add agents using addAgent() and make an initial movement request using requestMoveTarget().
A common process for managing the crowd is as follows:
Call update() to allow the crowd to manage its agents.
Retrieve agent information using getActiveAgents().
Make movement requests using requestMoveTarget() when movement goal changes.
Repeat every frame.
Some agent configuration settings can be updated using updateAgentParameters(). But the crowd owns the agent position. So it is not possible to update an active agent's position. If agent position must be fed back into the crowd, the agent must be removed and re-added.
Notes:
- Path related information is available for newly added agents only after an update() has been performed.
- Agent objects are kept in a pool and re-used. So it is important when using agent objects to check the value of dtCrowdAgent::active to determine if the agent is actually in use or not.
- This class is meant to provide 'local' movement. There is a limit of 256 polygons in the path corridor. So it is not meant to provide automatic pathfinding services over long distances.
| Name | dtCrowd |
| Type | class |
| Header File | /Engine/Source/Runtime/Navmesh/Public/DetourCrowd/DetourCrowd.h |
| Include Path | #include "DetourCrowd/DetourCrowd.h" |
Syntax
class dtCrowd
Constructors
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
dtCrowd() |
DetourCrowd/DetourCrowd.h |
Destructors
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
~dtCrowd() |
DetourCrowd/DetourCrowd.h |
Variables
Protected
| Name | Type | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|---|
| m_activeAgents | dtCrowdAgent ** | DetourCrowd/DetourCrowd.h | ||
| m_agentAnims | dtCrowdAgentAnimation * | DetourCrowd/DetourCrowd.h | ||
| m_agents | dtCrowdAgent * | DetourCrowd/DetourCrowd.h | ||
| m_agentStateCheckInterval | dtReal | [UE] time between attempts to restore agents state | DetourCrowd/DetourCrowd.h | |
| m_earlyReachTest | bool | [UE] if set, crowd agents will use early reach test | DetourCrowd/DetourCrowd.h | |
| m_ext | dtReal | DetourCrowd/DetourCrowd.h | ||
| m_filters | dtQueryFilter | DetourCrowd/DetourCrowd.h | ||
| m_grid | dtProximityGrid * | DetourCrowd/DetourCrowd.h | ||
| m_keepOffmeshConnections | bool | [UE] if set, offmesh connections won't be cut from corridor | DetourCrowd/DetourCrowd.h | |
| m_maxAgentRadius | dtReal | DetourCrowd/DetourCrowd.h | ||
| m_maxAgents | int | DetourCrowd/DetourCrowd.h | ||
| m_maxPathResult | int | DetourCrowd/DetourCrowd.h | ||
| m_navquery | dtNavMeshQuery * | DetourCrowd/DetourCrowd.h | ||
| m_numActiveAgents | int | DetourCrowd/DetourCrowd.h | ||
| m_obstacleQuery | dtObstacleAvoidanceQuery * | DetourCrowd/DetourCrowd.h | ||
| m_obstacleQueryParams | dtObstacleAvoidanceParams | DetourCrowd/DetourCrowd.h | ||
| m_pathOffsetRadiusMultiplier | dtReal | [UE] radius multiplier for offseting path around corners | DetourCrowd/DetourCrowd.h | |
| m_pathq | dtPathQueue | DetourCrowd/DetourCrowd.h | ||
| m_pathResult | dtPolyRef * | DetourCrowd/DetourCrowd.h | ||
| m_raycastFilter | dtQueryFilter | DetourCrowd/DetourCrowd.h | ||
| m_raycastSingleArea | bool | [UE] if set, path visibility optimization can't leave current area type | DetourCrowd/DetourCrowd.h | |
| m_separationDirFilter | dtReal | [UE] separation filter | DetourCrowd/DetourCrowd.h | |
| m_sharedBoundary | dtSharedBoundary | DetourCrowd/DetourCrowd.h | ||
| m_velocitySampleCount | int | DetourCrowd/DetourCrowd.h |
Functions
Public
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
int addAgent
(
const dtReal* pos, |
Adds a new agent to the crowd. | DetourCrowd/DetourCrowd.h | |
int cacheActiveAgents() |
Cache list of active agents | DetourCrowd/DetourCrowd.h | |
dtCrowdAgent ** getActiveAgents () |
Gets all cached active agents. | DetourCrowd/DetourCrowd.h | |
int getActiveAgents
(
dtCrowdAgent** agents, |
Gets the active agents int the agent pool. | DetourCrowd/DetourCrowd.h | |
const dtCrowdAgent * getAgent
(
const int idx |
Gets the specified agent from the pool. | DetourCrowd/DetourCrowd.h | |
const dtCrowdAgentAnimation * getAgentAnims() |
Gets all agent animations. | DetourCrowd/DetourCrowd.h | |
const int getAgentCount() |
The maximum number of agents that can be managed by the object. | DetourCrowd/DetourCrowd.h | |
int getAgentIndex
(
const dtCrowdAgent* agent |
DetourCrowd/DetourCrowd.h | ||
dtQueryFilter * getEditableFilter
(
const int idx |
Gets the filter used by the crowd. | DetourCrowd/DetourCrowd.h | |
const dtQueryFilter * getFilter
(
const int idx |
Gets the filter used by the crowd. | DetourCrowd/DetourCrowd.h | |
const dtProximityGrid * getGrid() |
Gets the crowd's proximity grid. | DetourCrowd/DetourCrowd.h | |
const dtNavMeshQuery * getNavMeshQuery() |
Gets the query object used by the crowd. | DetourCrowd/DetourCrowd.h | |
int getNumActiveAgents() |
DetourCrowd/DetourCrowd.h | ||
const dtObstacleAvoidanceParams * getObstacleAvoidanceParams
(
const int idx |
Gets the shared avoidance configuration for the specified index. | DetourCrowd/DetourCrowd.h | |
bool getObstacleAvoidancePattern
(
int idx, |
[UE] Gets the shared avoidance sampling pattern for the specified index. | DetourCrowd/DetourCrowd.h | |
const dtPathQueue * getPathQueue() |
Gets the crowd's path request queue. | DetourCrowd/DetourCrowd.h | |
const dtReal * getQueryExtents() |
Gets the search extents [(x, y, z)] used by the crowd for query operations. | DetourCrowd/DetourCrowd.h | |
const dtSharedBoundary * getSharedBoundary() |
Gets shared boundary cache. | DetourCrowd/DetourCrowd.h | |
int getVelocitySampleCount() |
Gets the velocity sample count. | DetourCrowd/DetourCrowd.h | |
bool init
(
const int maxAgents, |
Initializes the crowd. May be called more than once to purge and re-initialize the crowd. | DetourCrowd/DetourCrowd.h | |
bool initAvoidance
(
const int maxNeighbors, |
[UE] Initializes the avoidance query. | DetourCrowd/DetourCrowd.h | |
bool isOutsideCorridor
(
const int idx |
[UE] Check if agent moved away from its path corridor | DetourCrowd/DetourCrowd.h | |
void removeAgent
(
const int idx |
Removes the agent from the crowd. | DetourCrowd/DetourCrowd.h | |
bool requestMoveTarget
(
const int idx, |
Submits a new move request for the specified agent. | DetourCrowd/DetourCrowd.h | |
bool requestMoveVelocity
(
const int idx, |
Submits a new move request for the specified agent. | DetourCrowd/DetourCrowd.h | |
bool resetAgentVelocity
(
const int idx |
[UE] Resets agent's velocity | DetourCrowd/DetourCrowd.h | |
bool resetMoveTarget
(
const int idx |
Resets any request for the specified agent. | DetourCrowd/DetourCrowd.h | |
bool setAgentBackOnLink
(
const int idx |
[UE] Switch to offmesh link state | DetourCrowd/DetourCrowd.h | |
void setAgentCheckInterval
(
const dtReal t |
[UE] Set time between attempts to restore agents state | DetourCrowd/DetourCrowd.h | |
bool setAgentCorridor
(
const int idx, |
[UE] Set agent corridor, works only just after requesting move target when agent didn't start any pathfinding operations yet Use with caution! | DetourCrowd/DetourCrowd.h | |
bool setAgentWaiting
(
const int idx |
[UE] Switch to waiting state | DetourCrowd/DetourCrowd.h | |
void setEarlyReachTestOptimization
(
bool bEnable |
[UE] | DetourCrowd/DetourCrowd.h | |
void setObstacleAvoidanceParams
(
const int idx, |
Sets the shared avoidance configuration for the specified index. | DetourCrowd/DetourCrowd.h | |
void setObstacleAvoidancePattern
(
int idx, |
[UE] Sets the shared avoidance sampling pattern for the specified index. | DetourCrowd/DetourCrowd.h | |
void setPathOffsetRadiusMultiplier
(
dtReal RadiusMultiplier |
[UE] Set agent radius multiplier for offseting path from corners | DetourCrowd/DetourCrowd.h | |
void setPruneStartedOffmeshConnections
(
bool bRemoveFromCorridor |
[UE] Set offmesh connection pruning This will allow removing offmesh connection poly ref from corridor as soon as offmesh connection anim is triggered (default behavior) | DetourCrowd/DetourCrowd.h | |
void setSeparationFilter
(
dtReal InFilter |
[UE] Set separation filter param | DetourCrowd/DetourCrowd.h | |
void setSingleAreaVisibilityOptimization
(
bool bEnable |
[UE] Set visibility optimization to use single area raycasts This will prevent from cutting through polys marked as different area which could have been avoided in corridor's path | DetourCrowd/DetourCrowd.h | |
void update
(
const dtReal dt, |
Updates the steering and positions of all agents. | DetourCrowd/DetourCrowd.h | |
bool updateAgentFilter
(
const int idx, |
[UE] Updates the specified agent's query filter. | DetourCrowd/DetourCrowd.h | |
void updateAgentParameters
(
const int idx, |
Updates the specified agent's configuration. | DetourCrowd/DetourCrowd.h | |
void updateAgentState
(
const int idx, |
[UE] Refresh state of agent, used after completing movement through offmesh links | DetourCrowd/DetourCrowd.h | |
void updateStepAvoidance
(
const dtReal dt, |
[UE] Split update into several smaller components: avoidance | DetourCrowd/DetourCrowd.h | |
void updateStepCorridor
(
const dtReal dt, |
[UE] Split update into several smaller components: corridor updates at new position | DetourCrowd/DetourCrowd.h | |
void updateStepMove
(
const dtReal dt, |
[UE] Split update into several smaller components: integrate velocities and handle collisions | DetourCrowd/DetourCrowd.h | |
void updateStepNextMovePoint
(
const dtReal dt, |
[UE] Split update into several smaller components: next corner for move, trigger offmesh links | DetourCrowd/DetourCrowd.h | |
void updateStepOffMeshAnim
(
const dtReal dt, |
[UE] Split update into several smaller components: offmesh anims | DetourCrowd/DetourCrowd.h | |
void updateStepOffMeshVelocity
(
const dtReal dt, |
[UE] Split update into several smaller components: offmesh link velocity (instead of playing animation) | DetourCrowd/DetourCrowd.h | |
void updateStepPaths
(
const dtReal dt, |
[UE] Split update into several smaller components: path validity, path cache and path optimizations | DetourCrowd/DetourCrowd.h | |
void updateStepProximityData
(
const dtReal dt, |
[UE] Split update into several smaller components: neighbors and boundaries | DetourCrowd/DetourCrowd.h | |
void updateStepSteering
(
const dtReal dt, |
[UE] Split update into several smaller components: steering | DetourCrowd/DetourCrowd.h |
See Also
-
dtAllocCrowd()
-
dtFreeCrowd()
-
init()