/// Note: If a movement script (AIPath/RichAI/AILerp, anything implementing the IAstarAI interface) is attached to the same GameObject, this value will be driven by that script.
/// </summary>
publicfloatradius{
get{
if(ai!=null)returnai.radius;
returnradiusBackingField;
}
set{
if(ai!=null)ai.radius=value;
radiusBackingField=value;
}
}
/// <summary>
/// Height of the agent in world units.
/// Note: If a movement script (AIPath/RichAI/AILerp, anything implementing the IAstarAI interface) is attached to the same GameObject, this value will be driven by that script.
/// </summary>
publicfloatheight{
get{
if(ai!=null)returnai.height;
returnheightBackingField;
}
set{
if(ai!=null)ai.height=value;
heightBackingField=value;
}
}
/// <summary>A locked unit cannot move. Other units will still avoid it but avoidance quality is not the best.</summary>
[Tooltip("A locked unit cannot move. Other units will still avoid it. But avoidance quality is not the best")]
publicboollocked;
/// <summary>
/// Automatically set <see cref="locked"/> to true when desired velocity is approximately zero.
/// This prevents other units from pushing them away when they are supposed to e.g block a choke point.
///
/// When this is true every call to <see cref="SetTarget"/> or <see cref="Move"/> will set the <see cref="locked"/> field to true if the desired velocity
/// was non-zero or false if it was zero.
/// </summary>
[Tooltip("Automatically set #locked to true when desired velocity is approximately zero")]
publicboollockWhenNotMoving=false;
/// <summary>How far into the future to look for collisions with other agents (in seconds)</summary>
[Tooltip("How far into the future to look for collisions with other agents (in seconds)")]
publicfloatagentTimeHorizon=2;
/// <summary>How far into the future to look for collisions with obstacles (in seconds)</summary>
[Tooltip("How far into the future to look for collisions with obstacles (in seconds)")]
publicfloatobstacleTimeHorizon=0.5f;
/// <summary>
/// Max number of other agents to take into account.
/// A smaller value can reduce CPU load, a higher value can lead to better local avoidance quality.
/// </summary>
[Tooltip("Max number of other agents to take into account.\n"+
"A smaller value can reduce CPU load, a higher value can lead to better local avoidance quality.")]
publicintmaxNeighbours=10;
/// <summary>
/// Specifies the avoidance layer for this agent.
/// The <see cref="collidesWith"/> mask on other agents will determine if they will avoid this agent.
/// </summary>
publicRVOLayerlayer=RVOLayer.DefaultAgent;
/// <summary>
/// Layer mask specifying which layers this agent will avoid.
/// You can set it as CollidesWith = RVOLayer.DefaultAgent | RVOLayer.Layer3 | RVOLayer.Layer6 ...
///
/// This can be very useful in games which have multiple teams of some sort. For example you usually
/// want the agents in one team to avoid each other, but you do not want them to avoid the enemies.
///
/// This field only affects which other agents that this agent will avoid, it does not affect how other agents
/// react to this agent.
///
/// See: bitmasks (view in online documentation for working links)
/// This can be good way to reduce "wall hugging" behaviour.
///
/// Deprecated: This feature is currently disabled as it didn't work that well and was tricky to support after some changes to the RVO system. It may be enabled again in a future version.
/// </summary>
[HideInInspector]
[System.Obsolete]
publicfloatwallAvoidForce=1;
/// <summary>
/// How much the wallAvoidForce decreases with distance.
/// The strenght of avoidance is:
/// <code> str = 1/dist*wallAvoidFalloff </code>
///
/// See: wallAvoidForce
///
/// Deprecated: This feature is currently disabled as it didn't work that well and was tricky to support after some changes to the RVO system. It may be enabled again in a future version.
/// Center of the agent relative to the pivot point of this game object.
/// Note: If a movement script (AIPath/RichAI/AILerp, anything implementing the IAstarAI interface) is attached to the same GameObject, this value will be driven by that script.
/// </summary>
publicfloatcenter{
get{
// With an AI attached, this will always be driven to height/2 because the movement script expects the object position to be at its feet
if(mode!=null&&mode.Value!=MovementPlane.Arbitrary)thrownewSystem.InvalidOperationException("Cannot set the movement plane unless the RVOSimulator's movement plane setting is set to Arbitrary.");
movementPlaneBackingField=value;
}
}
/// <summary>Reference to the internal agent</summary>
publicIAgentrvoAgent{get;privateset;}
/// <summary>Reference to the rvo simulator</summary>
/// Direction and distance to move in a single frame to avoid obstacles.
///
/// The position of the agent is taken from the attached movement script's position (see <see cref="Pathfinding.IAstarAI.position)"/> or if none is attached then transform.position.
/// </summary>
/// <param name="deltaTime">How far to move [seconds].
// Note: We need to set this during UpdateAgentProperties to avoid a race condition.
// The HierarchicalNodeIndex, which is what is stored in the rvoAgent, can be invalidated by graph updates.
// So we must ensure that there cannot be any graph updates between when we set this, and when the simulation step happens.
// So setting it here, which is right before the simulation step, is a good option.
rvoAgent.SetObstacleQuery(obstacleQuery);
obstacleQuery=null;
}
/// <summary>
/// Set the target point for the agent to move towards.
/// Similar to the <see cref="Move"/> method but this is more flexible.
/// It is also better to use near the end of the path as when using the Move
/// method the agent does not know where to stop, so it may overshoot the target.
/// When using this method the agent will not overshoot the target.
/// The agent will assume that it will stop when it reaches the target so make sure that
/// you don't place the point too close to the agent if you actually just want to move in a
/// particular direction.
///
/// The target point is assumed to stay the same until something else is requested (as opposed to being reset every frame).
///
/// See: Also take a look at the documentation for <see cref="IAgent.SetTarget"/> which has a few more details.
/// See: <see cref="Move"/>
/// </summary>
/// <param name="pos">Point in world space to move towards.</param>
/// <param name="speed">Desired speed in world units per second.</param>
/// <param name="maxSpeed">Maximum speed in world units per second.
/// The agent will use this speed if it is necessary to avoid collisions with other agents.
/// Should be at least as high as speed, but it is recommended to use a slightly higher value than speed (for example speed*1.2).</param>
/// <param name="endOfPath">Point in world space which is the agent's final desired destination on the navmesh.
/// This is typically the end of the path the agent is following.
/// May be set to (+inf,+inf,+inf) to mark the agent as not having a well defined end of path.
/// If this is set, multiple agents with roughly the same end of path will crowd more naturally around this point.
/// They will be able to realize that they cannot get closer if there are many agents trying to get closer to the same destination and then stop.</param>