Skip to content
Tim edited this page Sep 23, 2023 · 5 revisions

Agent

(See "Add agent to a simulation")

What's an Agent?

An agent represent a single moving entity within the simulation. It has a desired velocity which the simulation is going to use as a base for various maths in order to find a final velocity, which represent an agent' attempt at avoiding collision with other agents and obstacles registered within the simulation.

An agent is a two-part data object. The first one is a managed object, Agent, that the simulation read from before running a step, and writes to after the simulation step is complete. The relevant data is captured into an AgentData struct (to enable thread safety within the job system).

This matters because it means any update done to an agent while a simulation step is running will only be reflected in the next step.

Agent.cs


Main properties

pos

Gets or sets the position of the agent.

While the simulation will update this after each steps, you can manually set the value at any time (before a step) to indicate the current position of an agent in space.

prefVelocity

Gets or sets the preferred velocity of the agent. This is the 'ideal,' desired velocity.

velocity

Gets or sets the simulated, collision-free velocity of the agent.

This property is updated by the simulation after each step, modifying it manually will have no effect. Instead, use prefVelocity to set the desired velocity.

height

Gets or sets the height of the agent.

This field is used in conjunction with pos for a variety of checks on the "other plane" (i.e, Z if you selected simulation over XY, Y if you selected XZ).

radius

Gets or sets the radius of the agent when resolving agent-agent collisions.

radiusObst

Gets or sets the radius of the agent when resolving agent-obstacle collisions.

Another way to look at the two radius is: radiusObst represent the actual, incompressible radius of an agent, while radius is more like a "personal space" other agents will be respectful of. Generally there is no reason to have different values here, although it can lead very interesting results to play with both.


Relation to context

maxSpeed

Gets or sets the maximum allowed speed of the agent.

In order to solve the simulation, it can sometimes be helpful for some agent to speed up their movement temporarily (to unblock a situation), this field controls how much faster/slower in relation to the prefVelocity.

maxNeighbors

Gets or sets the maximum number of neighbors this agent accounts for in the simulation.

The higher this value is (10+), the more "aware and predictive of others" an agent will be; Lower values (0-10), the more "reckless and disrepectful" an agent will be.

neighborDist

Gets or sets the maximum distance at which this agent considers avoiding other agents.

timeHorizon

Gets or sets the parameter used to modulate distance checks toward other agents within the simulation.

timeHorizonObst

Gets or sets the parameter used to modulate distance checks toward obstacles within the simulation.


Flags

layerOccupation

Gets or sets the layers on which this agent is physically present and affects other agents' navigation.

layerIgnore

Gets or sets the layers that are ignored while resolving the simulation.

navigationEnabled

Gets or sets whether this agent's navigation is controlled by the simulation.

Note that for the sake of more accurate simulations, it's still very useful to set an agent' prefVelocity even if its navigation is disabled. Other agent can still make use of the information.

collisionEnabled

Gets or sets whether this agent's collision is enabled.

If disabled, it basically means "avoid other agents, but they won't avoid you".