Class NavCrowd
Navigation steering behaviors system for a group of agents. Handles avoidance between agents by using an adaptive RVO sampling calculation.
Assembly: FlaxEngine.dll
File: Engine/Navigation/NavCrowd.h
Syntax
public class NavCrowd : public ScriptingObject
Constructors
Methods
Adds a new agent to the crowd.
Declaration
public int32 AddAgent(const Vector3& position, const NavAgentProperties& properties)
Parameters
Returns
int32
The agent unique ID or -1 if failed to add it (eg. too many active agents).
|
Gets the agent current position.
Declaration
public Vector3 GetAgentPosition(int32 id) const
Parameters
Returns
Vector3
The agent current position.
|
Gets the agent current velocity (direction * speed).
Declaration
public Vector3 GetAgentVelocity(int32 id) const
Parameters
Returns
Vector3
The agent current velocity (direction * speed).
|
Declaration
public bool Init(const NavAgentProperties& agentProperties, int32 maxAgents=25)
Parameters
NavAgentProperties
agentProperties
The properties of the agents that will be added to the crowd.
|
int32
maxAgents
maximum number of agents the crowd can manage.
|
Returns
bool
True if failed, otherwise false.
|
Declaration
public bool Init(float maxAgentRadius, int32 maxAgents, NavMeshRuntime* navMesh)
Parameters
float
maxAgentRadius
The maximum radius of any agent that will be added to the crowd.
|
int32
maxAgents
maximum number of agents the crowd can manage.
|
NavMeshRuntime
navMesh
The navigation mesh to use for crowd movement planning.
|
Returns
bool
True if failed, otherwise false.
|
Declaration
public bool Init(float maxAgentRadius=100.0f, int32 maxAgents=25, NavMesh* navMesh=nullptr)
Parameters
float
maxAgentRadius
The maximum radius of any agent that will be added to the crowd.
|
int32
maxAgents
maximum number of agents the crowd can manage.
|
NavMesh
navMesh
The navigation mesh to use for crowd movement planning. Use null to pick the first navmesh.
|
Returns
bool
True if failed, otherwise false.
|
Removes the agent of the given ID.
Declaration
public void RemoveAgent(int32 id)
Parameters
Resets any movement request for the specified agent.
Declaration
public void ResetAgentMove(int32 id)
Parameters
Updates the agent movement target position.
Declaration
public void SetAgentMoveTarget(int32 id, const Vector3& position)
Parameters
int32
id
The agent ID.
|
Vector3
position
The agent target position.
|
Updates the agent movement target velocity (direction * speed).
Declaration
public void SetAgentMoveVelocity(int32 id, const Vector3& velocity)
Parameters
int32
id
The agent ID.
|
Vector3
velocity
The agent target velocity (direction * speed).
|
Sets the agent current position.
Declaration
public void SetAgentPosition(int32 id, const Vector3& position)
Parameters
int32
id
The agent ID.
|
Vector3
position
The agent position.
|
Updates the agent properties.
Declaration
public void SetAgentProperties(int32 id, const NavAgentProperties& properties)
Parameters
Sets the agent current velocity (direction * speed).
Declaration
public void SetAgentVelocity(int32 id, const Vector3& velocity)
Parameters
int32
id
The agent ID.
|
Vector3
velocity
The agent velocity (direction * speed).
|
Updates the steering and positions of all agents.
Declaration
public void Update(float dt)
Parameters
float
dt
The simulation update delta time (in seconds).
|