dtCrowd

Provides local steering behaviors for a group of agents.

Windows
MacOS
Linux

References

Module

Navmesh

Header

/Engine/Source/Runtime/Navmesh/Public/DetourCrowd/DetourCrowd.h

Include

#include "DetourCrowd/DetourCrowd.h"

Syntax

class dtCrowd

Remarks

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](API\Runtime\Navmesh\DetourCrowd\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.

Constructors

Name Description

Public function

dtCrowd()

Destructors

Name Description

Public function

~dtCrowd()

Functions

Name Description

Public function

int

 

addAgent

(
    const float* pos,
    const dtCrowdAgentParams& params,
    const dtQueryFilter* filter
)

Adds a new agent to the crowd.

Public function

int

 

cacheActiveAgents()

Cache list of active agents

Public function Const

dtCrowdAgent...

 

getActiveAgents()

Gets all cached active agents.

Public function

int

 

getActiveAgents

(
    dtCrowdAgent** agents,
    const int maxAgents
)

Gets the active agents int the agent pool.

Public function

const dtCrow...

 

getAgent

(
    const int idx
)

Gets the specified agent from the pool.

Public function Const

const dtCrow...

 

getAgentAnims()

Gets all agent animations.

Public function Const

const int

 

getAgentCount()

The maximum number of agents that can be managed by the object.

Public function Const

int

 

getAgentIndex

(
    const dtCrowdAgent* agent
)

Public function

dtQueryFilte...

 

getEditableFilter

(
    const int idx
)

Gets the filter used by the crowd.

Public function Const

const dtQuer...

 

getFilter

(
    const int idx
)

Gets the filter used by the crowd.

Public function Const

const dtProx...

 

getGrid()

Gets the crowd's proximity grid.

Public function Const

const dtNavM...

 

getNavMeshQuery()

Gets the query object used by the crowd.

Public function Const

int

 

getNumActiveAgents()

Public function Const

const dtObst...

 

getObstacleAvoidanceParams

(
    const int idx
)

Gets the shared avoidance configuration for the specified index.

Public function

bool

 

getObstacleAvoidancePattern

(
    int idx,
    float* angles,
    float* radii,
    int* nsamples
)

[UE4] Gets the shared avoidance sampling pattern for the specified index.

Public function Const

const dtPath...

 

getPathQueue()

Gets the crowd's path request queue.

Public function Const

const float ...

 

getQueryExtents()

Gets the search extents [(x, y, z)] used by the crowd for query operations.

Public function Const

const dtShar...

 

getSharedBoundary()

Gets shared boundary cache.

Public function Const

int

 

getVelocitySampleCount()

Gets the velocity sample count.

Public function

bool

 

init

(
    const int maxAgents,
    const float maxAgentRadius,
    dtNavMesh* nav
)

Initializes the crowd.

May be called more than once to purge and re-initialize the crowd.

Public function

bool

 

initAvoidance

(
    const int maxNeighbors,
    const int maxWalls,
    const int maxCustomPatterns
)

[UE4] Initializes the avoidance query.

Public function Const

bool

 

isOutsideCorridor

(
    const int idx
)

[UE4] Check if agent moved away from its path corridor

Public function

void

 

removeAgent

(
    const int idx
)

Removes the agent from the crowd.

Public function

bool

 

requestMoveTarget

(
    const int idx,
    dtPolyRef ref,
    const float* pos
)

Submits a new move request for the specified agent.

Public function

bool

 

requestMoveVelocity

(
    const int idx,
    const float* vel
)

Submits a new move request for the specified agent.

Public function

bool

 

resetAgentVelocity

(
    const int idx
)

[UE4] Resets agent's velocity

Public function

bool

 

resetMoveTarget

(
    const int idx
)

Resets any request for the specified agent.

Public function

bool

 

setAgentBackOnLink

(
    const int idx
)

[UE4] Switch to offmesh link state

Public function

void

 

setAgentCheckInterval

(
    const float t
)

[UE4] Set time between attempts to restore agents state

Public function

bool

 

setAgentCorridor

(
    const int idx,
    const dtPolyRef* path,
    const int npath
)

[UE4] Set agent corridor, works only just after requesting move target when agent didn't start any pathfinding operations yet Use with caution!

Public function

bool

 

setAgentWaiting

(
    const int idx
)

[UE4] Switch to waiting state

Public function

void

 

setEarlyReachTestOptimization

(
    bool bEnable
)

[UE4]

Public function

void

 

setObstacleAvoidanceParams

(
    const int idx,
    const dtObstacleAvoidanceParams...
)

Sets the shared avoidance configuration for the specified index.

Public function

void

 

setObstacleAvoidancePattern

(
    int idx,
    const float* angles,
    const float* radii,
    int nsamples
)

[UE4] Sets the shared avoidance sampling pattern for the specified index.

Public function

void

 

setPathOffsetRadiusMultiplier

(
    float RadiusMultiplier
)

[UE4] Set agent radius multiplier for offseting path from corners

Public function

void

 

setPruneStartedOffmeshConnections

(
    bool bRemoveFromCorridor
)

[UE4] Set offmesh connection pruning This will allow removing offmesh connection poly ref from corridor as soon as offmesh connection anim is triggered (default behavior)

Public function

void

 

setSeparationFilter

(
    float InFilter
)

[UE4] Set separation filter param

Public function

void

 

setSingleAreaVisibilityOptimization

(
    bool bEnable
)

[UE4] 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

Public function

void

 

update

(
    const float dt,
    dtCrowdAgentDebugInfo* debug
)

Updates the steering and positions of all agents.

Public function

bool

 

updateAgentFilter

(
    const int idx,
    const dtQueryFilter* filter
)

[UE4] Updates the specified agent's query filter.

Public function

void

 

updateAgentParameters

(
    const int idx,
    const dtCrowdAgentParams& params
)

Updates the specified agent's configuration.

Public function

void

 

updateAgentState

(
    const int idx,
    bool repath
)

[UE4] Refresh state of agent, used after completing movement through offmesh links

Public function

void

 

updateStepAvoidance

(
    const float dt,
    dtCrowdAgentDebugInfo* debug
)

[UE4] Split update into several smaller components: avoidance

Public function

void

 

updateStepCorridor

(
    const float dt,
    dtCrowdAgentDebugInfo* debug
)

[UE4] Split update into several smaller components: corridor updates at new position

Public function

void

 

updateStepMove

(
    const float dt,
    dtCrowdAgentDebugInfo* debug
)

[UE4] Split update into several smaller components: integrate velocities and handle collisions

Public function

void

 

updateStepNextMovePoint

(
    const float dt,
    dtCrowdAgentDebugInfo* debug
)

[UE4] Split update into several smaller components: next corner for move, trigger offmesh links

Public function

void

 

updateStepOffMeshAnim

(
    const float dt,
    dtCrowdAgentDebugInfo* debug
)

[UE4] Split update into several smaller components: offmesh anims

Public function

void

 

updateStepOffMeshVelocity

(
    const float dt,
    dtCrowdAgentDebugInfo* debug
)

[UE4] Split update into several smaller components: offmesh link velocity (instead of playing animation)

Public function

void

 

updateStepPaths

(
    const float dt,
    dtCrowdAgentDebugInfo* debug
)

[UE4] Split update into several smaller components: path validity, path cache and path optimizations

Public function

void

 

updateStepProximityData

(
    const float dt,
    dtCrowdAgentDebugInfo* debug
)

[UE4] Split update into several smaller components: neighbors and boundaries

Public function

void

 

updateStepSteering

(
    const float dt,
    dtCrowdAgentDebugInfo* debug
)

[UE4] Split update into several smaller components: steering

See Also

Help shape the future of Unreal Engine documentation! Tell us how we're doing so we can serve you better.
Take our survey
Dismiss