Class NavCrowd
Navigation steering behaviors system for a group of agents. Handles avoidance between agents by using an adaptive RVO sampling calculation.
Assembly: FlaxEngine.CSharp.dll
Syntax
[Unmanaged]
public class NavCrowd : Object
Constructors
Initializes a new instance of the NavCrowd.
Declaration
Methods
Adds a new agent to the crowd.
Declaration
[Unmanaged]
public int AddAgent(Vector3 position, NavAgentProperties properties)
Parameters
Returns
System.Int32
The agent unique ID or -1 if failed to add it (eg. too many active agents).
|
Gets the agent current position.
Declaration
[Unmanaged]
public Vector3 GetAgentPosition(int id)
Parameters
System.Int32
id
The agent ID.
|
Returns
Vector3
The agent current position.
|
Gets the agent current velocity (direction * speed).
Declaration
[Unmanaged]
public Vector3 GetAgentVelocity(int id)
Parameters
System.Int32
id
The agent ID.
|
Returns
Vector3
The agent current velocity (direction * speed).
|
Declaration
[Unmanaged]
public bool Init(NavAgentProperties agentProperties, int maxAgents = 25)
Parameters
NavAgentProperties
agentProperties
The properties of the agents that will be added to the crowd.
|
System.Int32
maxAgents
maximum number of agents the crowd can manage.
|
Returns
System.Boolean
True if failed, otherwise false.
|
Declaration
[Unmanaged]
public bool Init(float maxAgentRadius = 100F, int maxAgents = 25, NavMesh navMesh = null)
Parameters
System.Single
maxAgentRadius
The maximum radius of any agent that will be added to the crowd.
|
System.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
System.Boolean
True if failed, otherwise false.
|
Removes the agent of the given ID.
Declaration
[Unmanaged]
public void RemoveAgent(int id)
Parameters
Resets any movement request for the specified agent.
Declaration
[Unmanaged]
public void ResetAgentMove(int id)
Parameters
System.Int32
id
The agent ID.
|
Updates the agent movement target position.
Declaration
[Unmanaged]
public void SetAgentMoveTarget(int id, Vector3 position)
Parameters
System.Int32
id
The agent ID.
|
Vector3
position
The agent target position.
|
Updates the agent movement target velocity (direction * speed).
Declaration
[Unmanaged]
public void SetAgentMoveVelocity(int id, Vector3 velocity)
Parameters
System.Int32
id
The agent ID.
|
Vector3
velocity
The agent target velocity (direction * speed).
|
Sets the agent current position.
Declaration
[Unmanaged]
public void SetAgentPosition(int id, Vector3 position)
Parameters
System.Int32
id
The agent ID.
|
Vector3
position
The agent position.
|
Updates the agent properties.
Declaration
[Unmanaged]
public void SetAgentProperties(int id, NavAgentProperties properties)
Parameters
Sets the agent current velocity (direction * speed).
Declaration
[Unmanaged]
public void SetAgentVelocity(int id, Vector3 velocity)
Parameters
System.Int32
id
The agent ID.
|
Vector3
velocity
The agent velocity (direction * speed).
|
Updates the steering and positions of all agents.
Declaration
[Unmanaged]
public void Update(float dt)
Parameters
System.Single
dt
The simulation update delta time (in seconds).
|
Extension Methods