A* Pathfinding Project  4.2.3
The A* Pathfinding Project for Unity 3D
RichAI Class Reference

Advanced AI for navmesh based graphs. More...

Detailed Description

Advanced AI for navmesh based graphs.

A* Pro Feature:
This is an A* Pathfinding Project Pro feature only. This function/class/variable might not exist in the Free version of the A* Pathfinding Project or the functionality might be limited
The Pro version can be bought here

Public Member Functions

override void SearchPath ()
 Recalculate the current path. More...
 
override void Teleport (Vector3 newPosition, bool clearPath=true)
 Instantly move the agent to a new position. More...
 
void UpdatePath ()
 Force recalculation of the current path. More...
 
- Public Member Functions inherited from AIBase
virtual void FinalizeMovement (Vector3 nextPosition, Quaternion nextRotation)
 Moves the agent to a position. More...
 
virtual Vector3 GetFeetPosition ()
 Position of the base of the character. More...
 
virtual void Move (Vector3 deltaPosition)
 Move the agent. More...
 
void MovementUpdate (float deltaTime, out Vector3 nextPosition, out Quaternion nextRotation)
 Calculate how the character wants to move during this frame. More...
 
void SetPath (Path path)
 Make the AI follow the specified path. More...
 
Quaternion SimulateRotationTowards (Vector3 direction, float maxDegrees)
 Simulates rotating the agent towards the specified direction and returns the new rotation. More...
 
- Public Member Functions inherited from IAstarAI
void FinalizeMovement (Vector3 nextPosition, Quaternion nextRotation)
 Move the agent. More...
 
void Move (Vector3 deltaPosition)
 Move the agent. More...
 
void MovementUpdate (float deltaTime, out Vector3 nextPosition, out Quaternion nextRotation)
 Calculate how the character wants to move during this frame. More...
 
void SetPath (Path path)
 Make the AI follow the specified path. More...
 

Public Attributes

float acceleration = 5
 Max acceleration of the agent. More...
 
float endReachedDistance = 0.01f
 Max distance to the endpoint to consider it reached. More...
 
bool funnelSimplification = false
 Use funnel simplification. More...
 
System.Func< RichSpecial, IEnumerator > onTraverseOffMeshLink
 Called when the agent starts to traverse an off-mesh link. More...
 
float rotationSpeed = 360
 Max rotation speed of the agent. More...
 
float slowdownTime = 0.5f
 How long before reaching the end of the path to start to slow down. More...
 
bool slowWhenNotFacingTarget = true
 Slow down when not facing the target direction. More...
 
float wallDist = 1
 Walls within this range will be used for avoidance. More...
 
float wallForce = 3
 Force to avoid walls with. More...
 
- Public Attributes inherited from AIBase
bool canMove = true
 Enables or disables movement completely. More...
 
bool canSearch = true
 Enables or disables recalculating the path at regular intervals. More...
 
bool enableRotation = true
 If true, the AI will rotate to face the movement direction. More...
 
Vector3 gravity = new Vector3(float.NaN, float.NaN, float.NaN)
 Gravity to use. More...
 
LayerMask groundMask = -1
 Layer mask to use for ground placement. More...
 
float height = 2
 Radius of the agent in world units. More...
 
float maxSpeed = 1
 Max speed in world units per second. More...
 
IMovementPlane movementPlane = GraphTransform.identityTransform
 Plane which this agent is moving in. More...
 
OrientationMode orientation = OrientationMode.ZAxisForward
 Determines which direction the agent moves in. More...
 
float radius = 0.5f
 Height of the agent in world units. More...
 
float repathRate = 0.5f
 Determines how often the agent will search for new paths (in seconds). More...
 
bool updatePosition = true
 Determines if the character's position should be coupled to the Transform's position. More...
 
bool updateRotation = true
 Determines if the character's rotation should be coupled to the Transform's rotation. More...
 

Protected Member Functions

override Vector3 ClampToNavmesh (Vector3 position, out bool positionChanged)
 Constrains the character's position to lie on the navmesh. More...
 
override void MovementUpdateInternal (float deltaTime, out Vector3 nextPosition, out Quaternion nextRotation)
 Called during either Update or FixedUpdate depending on if rigidbodies are used for movement or not. More...
 
void NextPart ()
 Declare that the AI has completely traversed the current part. More...
 
override void OnDisable ()
 Called when the component is disabled. More...
 
override void OnDrawGizmos ()
 
override void OnPathComplete (Path p)
 Called when a requested path has been calculated. More...
 
virtual void OnTargetReached ()
 Called when the end of the path is reached. More...
 
override int OnUpgradeSerializedData (int version, bool unityThread)
 Handle serialization backwards compatibility. More...
 
IEnumerator TraverseOffMeshLinkFallback (RichSpecial link)
 Fallback for traversing off-mesh links in case onTraverseOffMeshLink is not set. More...
 
virtual IEnumerator TraverseSpecial (RichSpecial link)
 Traverses an off-mesh link. More...
 
virtual Vector3 UpdateTarget (RichFunnel fn)
 
- Protected Member Functions inherited from AIBase
 AIBase ()
 
void ApplyGravity (float deltaTime)
 Accelerates the agent downwards. More...
 
Vector2 CalculateDeltaToMoveThisFrame (Vector2 position, float distanceToEndOfPath, float deltaTime)
 Calculates how far to move during a single frame. More...
 
virtual void CalculatePathRequestEndpoints (out Vector3 start, out Vector3 end)
 Outputs the start point and end point of the next automatic path request. More...
 
void CancelCurrentPathRequest ()
 
virtual void FindComponents ()
 
virtual void FixedUpdate ()
 Called every physics update. More...
 
virtual void OnDrawGizmosSelected ()
 
virtual void OnEnable ()
 Called when the component is enabled. More...
 
Vector3 RaycastPosition (Vector3 position, float lastElevation)
 Checks if the character is grounded and prevents ground penetration. More...
 
override void Reset ()
 Handle serialization backwards compatibility. More...
 
Quaternion SimulateRotationTowards (Vector2 direction, float maxDegrees)
 Simulates rotating the agent towards the specified direction and returns the new rotation. More...
 
virtual void Start ()
 Starts searching for paths. More...
 
virtual void Update ()
 Called every frame. More...
 
void UpdateVelocity ()
 
- Protected Member Functions inherited from VersionedMonoBehaviour
virtual void Awake ()
 

Protected Attributes

bool delayUpdatePath
 
float distanceToSteeringTarget = float.PositiveInfinity
 Distance to steeringTarget in the movement plane. More...
 
bool lastCorner
 
readonly List< Vector3 > nextCorners = new List<Vector3>()
 
readonly RichPath richPath = new RichPath()
 Holds the current path that this agent is following. More...
 
readonly List< Vector3 > wallBuffer = new List<Vector3>()
 
- Protected Attributes inherited from AIBase
CharacterController controller
 Cached CharacterController component. More...
 
Vector2 lastDeltaPosition
 Amount which the character wants or tried to move with during the last frame. More...
 
float lastDeltaTime
 Delta time used for movement during the last frame. More...
 
float lastRepath = float.NegativeInfinity
 Time when the last path request was started. More...
 
int prevFrame
 Last frame index when prevPosition1 was updated. More...
 
Vector3 prevPosition1
 Position of the character at the end of the last frame. More...
 
Vector3 prevPosition2
 Position of the character at the end of the frame before the last frame. More...
 
Rigidbody rigid
 Cached Rigidbody component. More...
 
Rigidbody2D rigid2D
 Cached Rigidbody component. More...
 
RVOController rvoController
 Cached RVOController component. More...
 
Seeker seeker
 Cached Seeker component. More...
 
Vector3 simulatedPosition
 Position of the agent. More...
 
Quaternion simulatedRotation
 Rotation of the agent. More...
 
Transform tr
 Cached Transform component. More...
 
Vector2 velocity2D
 Current desired velocity of the agent (does not include local avoidance and physics). More...
 
float verticalVelocity
 Velocity due to gravity. More...
 
bool waitingForPathCalculation = false
 Only when the previous path has been calculated should the script consider searching for a new path. More...
 

Static Protected Attributes

static readonly Color GizmoColorPath = new Color(8.0f/255, 78.0f/255, 194.0f/255)
 

Properties

Animation anim [get, set]
 Anim for off-mesh links. More...
 
bool ApproachingPartEndpoint [get]
 
bool approachingPartEndpoint [get]
 True if approaching the last waypoint in the current part of the path. More...
 
bool ApproachingPathEndpoint [get]
 
bool approachingPathEndpoint [get]
 True if approaching the last waypoint of all parts in the current path. More...
 
bool IAstarAI. canMove [get, set]
 Enables or disables movement completely. More...
 
bool IAstarAI. canSearch [get, set]
 Enables or disables recalculating the path at regular intervals. More...
 
float DistanceToNextWaypoint [get]
 
bool hasPath [get]
 True if this agent currently has a path that it follows. More...
 
float IAstarAI. height [get, set]
 Radius of the agent in world units. More...
 
float IAstarAI. maxSpeed [get, set]
 Max speed in world units per second. More...
 
Vector3 NextWaypoint [get]
 Waypoint that the agent is moving towards. More...
 
bool PathPending [get]
 True if a path to the target is currently being calculated. More...
 
bool pathPending [get]
 True if a path is currently being calculated. More...
 
Vector3 IAstarAI. position [get]
 Position of the agent. More...
 
float IAstarAI. radius [get, set]
 Height of the agent in world units. More...
 
bool reachedDestination [get]
 True if the ai has reached the destination. More...
 
bool reachedEndOfPath [get]
 True if the agent has reached the end of the current path. More...
 
float remainingDistance [get]
 Remaining distance along the current path to the end of the path. More...
 
bool repeatedlySearchPaths [get, set]
 Search for new paths repeatedly. More...
 
override bool shouldRecalculatePath [get]
 
Vector3 steeringTarget [get, protected set]
 Point on the path which the agent is currently moving towards. More...
 
Vector3 TargetPoint [get]
 Current waypoint that the agent is moving towards. More...
 
bool TargetReached [get]
 True if the end of the path has been reached. More...
 
bool traversingOffMeshLink [get, protected set]
 
bool TraversingSpecial [get]
 
Vector3 Velocity [get]
 Current velocity of the agent. More...
 
- Properties inherited from AIBase
float centerOffset [get, set]
 Offset along the Y coordinate for the ground raycast start position. More...
 
Vector3 desiredVelocity [get]
 Velocity that this agent wants to move with. More...
 
Vector3 destination [get, set]
 Position in the world that this agent should move to. More...
 
bool isStopped [get, set]
 Gets or sets if the agent should stop moving. More...
 
System.Action onSearchPath [get, set]
 Called when the agent recalculates its path. More...
 
Vector3 position [get]
 Position of the agent. More...
 
Quaternion rotation [get]
 Rotation of the agent. More...
 
bool rotationIn2D [get, set]
 If true, the forward axis of the character will be along the Y axis instead of the Z axis. More...
 
virtual bool shouldRecalculatePath [get]
 True if the path should be automatically recalculated as soon as possible. More...
 
Transform target [get, set]
 Target to move towards. More...
 
bool usingGravity [get, private set]
 Indicates if gravity is used during this frame. More...
 
Vector3 velocity [get]
 Actual velocity that the agent is moving with. More...
 
- Properties inherited from IAstarAI
bool canMove [get, set]
 Enables or disables movement completely. More...
 
bool canSearch [get, set]
 Enables or disables recalculating the path at regular intervals. More...
 
Vector3 desiredVelocity [get]
 Velocity that this agent wants to move with. More...
 
Vector3 destination [get, set]
 Position in the world that this agent should move to. More...
 
bool hasPath [get]
 True if this agent currently has a path that it follows. More...
 
float height [get, set]
 Radius of the agent in world units. More...
 
bool isStopped [get, set]
 Gets or sets if the agent should stop moving. More...
 
float maxSpeed [get, set]
 Max speed in world units per second. More...
 
System.Action onSearchPath [get, set]
 Called when the agent recalculates its path. More...
 
bool pathPending [get]
 True if a path is currently being calculated. More...
 
Vector3 position [get]
 Position of the agent. More...
 
float radius [get, set]
 Height of the agent in world units. More...
 
bool reachedDestination [get]
 True if the ai has reached the destination. More...
 
bool reachedEndOfPath [get]
 True if the agent has reached the end of the current path. More...
 
float remainingDistance [get]
 Remaining distance along the current path to the end of the path. More...
 
Quaternion rotation [get]
 Rotation of the agent. More...
 
Vector3 steeringTarget [get]
 Point on the path which the agent is currently moving towards. More...
 
Vector3 velocity [get]
 Actual velocity that the agent is moving with. More...
 

Private Member Functions

Vector2 CalculateWallForce (Vector2 position, float elevation, Vector2 directionToTarget)
 
void FinalMovement (Vector3 position3D, float deltaTime, float distanceToEndOfPath, float slowdownFactor, out Vector3 nextPosition, out Quaternion nextRotation)
 
void TraverseFunnel (RichFunnel fn, float deltaTime, out Vector3 nextPosition, out Quaternion nextRotation)
 

Private Attributes

Animation animCompatibility
 

Additional Inherited Members

- Static Public Attributes inherited from AIBase
static readonly Color ShapeGizmoColor = new Color(240/255f, 213/255f, 30/255f)
 

Member Function Documentation

◆ CalculateWallForce()

Vector2 CalculateWallForce ( Vector2  position,
float  elevation,
Vector2  directionToTarget 
)
private

◆ ClampToNavmesh()

override Vector3 ClampToNavmesh ( Vector3  position,
out bool  positionChanged 
)
protectedvirtual

Constrains the character's position to lie on the navmesh.

Not all movement scripts have support for this.

Parameters
positionCurrent position of the character.
positionChangedTrue if the character's position was modified by this method.
Returns
New position of the character that has been clamped to the navmesh.

Reimplemented from AIBase.

◆ FinalMovement()

void FinalMovement ( Vector3  position3D,
float  deltaTime,
float  distanceToEndOfPath,
float  slowdownFactor,
out Vector3  nextPosition,
out Quaternion  nextRotation 
)
private

◆ MovementUpdateInternal()

override void MovementUpdateInternal ( float  deltaTime,
out Vector3  nextPosition,
out Quaternion  nextRotation 
)
protectedvirtual

Called during either Update or FixedUpdate depending on if rigidbodies are used for movement or not.

Implements AIBase.

◆ NextPart()

void NextPart ( )
protected

Declare that the AI has completely traversed the current part.

This will skip to the next part, or call OnTargetReached if this was the last part

◆ OnDisable()

override void OnDisable ( )
protectedvirtual

Called when the component is disabled.

Reimplemented from AIBase.

◆ OnDrawGizmos()

override void OnDrawGizmos ( )
protectedvirtual

Reimplemented from AIBase.

◆ OnPathComplete()

override void OnPathComplete ( Path  newPath)
protectedvirtual

Called when a requested path has been calculated.

Implements AIBase.

◆ OnTargetReached()

virtual void OnTargetReached ( )
protectedvirtual

Called when the end of the path is reached.

◆ OnUpgradeSerializedData()

override int OnUpgradeSerializedData ( int  version,
bool  unityThread 
)
protectedvirtual

Handle serialization backwards compatibility.

Reimplemented from AIBase.

◆ SearchPath()

override void SearchPath ( )
virtual

Recalculate the current path.

You can for example use this if you want very quick reaction times when you have changed the destination so that the agent does not have to wait until the next automatic path recalculation (see canSearch).

If there is an ongoing path calculation, it will be canceled, so make sure you leave time for the paths to get calculated before calling this function again. A canceled path will show up in the log with the message "Canceled by script" (see #Seeker.CancelCurrentPathRequest()).

If no destination has been set yet then nothing will be done.

Note
The path result may not become available until after a few frames. During the calculation time the pathPending property will return true.
See also
pathPending

Reimplemented from AIBase.

◆ Teleport()

override void Teleport ( Vector3  newPosition,
bool  clearPath = true 
)
virtual

Instantly move the agent to a new position.

This will trigger a path recalculation (if clearPath is true, which is the default) so if you want to teleport the agent and change its destination it is recommended that you set the destination before calling this method.

The current path will be cleared by default.

See also
Works similarly to Unity's NavmeshAgent.Warp.
SearchPath

When setting transform.position directly the agent will be clamped to the part of the navmesh it can reach, so it may not end up where you wanted it to. This ensures that the agent can move to any part of the navmesh.

Reimplemented from AIBase.

◆ TraverseFunnel()

void TraverseFunnel ( RichFunnel  fn,
float  deltaTime,
out Vector3  nextPosition,
out Quaternion  nextRotation 
)
private

◆ TraverseOffMeshLinkFallback()

IEnumerator TraverseOffMeshLinkFallback ( RichSpecial  link)
protected

Fallback for traversing off-mesh links in case onTraverseOffMeshLink is not set.

This will do a simple linear interpolation along the link.

◆ TraverseSpecial()

virtual IEnumerator TraverseSpecial ( RichSpecial  link)
protectedvirtual

Traverses an off-mesh link.

◆ UpdatePath()

void UpdatePath ( )

Force recalculation of the current path.

If there is an ongoing path calculation, it will be canceled (so make sure you leave time for the paths to get calculated before calling this function again).

Deprecated:
Use SearchPath instead

◆ UpdateTarget()

virtual Vector3 UpdateTarget ( RichFunnel  fn)
protectedvirtual

Member Data Documentation

◆ acceleration

float acceleration = 5

Max acceleration of the agent.

In world units per second per second.

◆ animCompatibility

Animation animCompatibility
private

◆ delayUpdatePath

bool delayUpdatePath
protected

◆ distanceToSteeringTarget

float distanceToSteeringTarget = float.PositiveInfinity
protected

Distance to steeringTarget in the movement plane.

◆ endReachedDistance

float endReachedDistance = 0.01f

Max distance to the endpoint to consider it reached.

See also
reachedEndOfPath
OnTargetReached

◆ funnelSimplification

bool funnelSimplification = false

Use funnel simplification.

On tiled navmesh maps, but sometimes on normal ones as well, it can be good to simplify the funnel as a post-processing step to make the paths straighter.

This has a moderate performance impact during frames when a path calculation is completed.

The RichAI script uses its own internal funnel algorithm, so you never need to attach the FunnelModifier component.

See also
Pathfinding.FunnelModifier

◆ GizmoColorPath

readonly Color GizmoColorPath = new Color(8.0f/255, 78.0f/255, 194.0f/255)
staticprotected

◆ lastCorner

bool lastCorner
protected

◆ nextCorners

readonly List<Vector3> nextCorners = new List<Vector3>()
protected

◆ onTraverseOffMeshLink

System.Func<RichSpecial, IEnumerator> onTraverseOffMeshLink

Called when the agent starts to traverse an off-mesh link.

Register to this callback to handle off-mesh links in a custom way.

If this event is set to null then the agent will fall back to traversing off-mesh links using a very simple linear interpolation.

void OnEnable () {
ai = GetComponent<RichAI>();
if (ai != null) ai.onTraverseOffMeshLink += TraverseOffMeshLink;
}
void OnDisable () {
if (ai != null) ai.onTraverseOffMeshLink -= TraverseOffMeshLink;
}
IEnumerator TraverseOffMeshLink (RichSpecial link) {
// Traverse the link over 1 second
float startTime = Time.time;
while (Time.time < startTime + 1) {
transform.position = Vector3.Lerp(link.first.position, link.second.position, Time.time - startTime);
yield return null;
}
transform.position = link.second.position;
}

◆ richPath

readonly RichPath richPath = new RichPath()
protected

Holds the current path that this agent is following.

◆ rotationSpeed

float rotationSpeed = 360

Max rotation speed of the agent.

In degrees per second.

◆ slowdownTime

float slowdownTime = 0.5f

How long before reaching the end of the path to start to slow down.

A lower value will make the agent stop more abruptly.

Note
The agent may require more time to slow down if its maximum acceleration is not high enough.

If set to zero the agent will not even attempt to slow down. This can be useful if the target point is not a point you want the agent to stop at but it might for example be the player and you want the AI to slam into the player.

Note
A value of zero will behave differently from a small but non-zero value (such as 0.0001). When it is non-zero the agent will still respect its acceleration when determining if it needs to slow down, but if it is zero it will disable that check. This is useful if the destination is not a point where you want the agent to stop.

◆ slowWhenNotFacingTarget

bool slowWhenNotFacingTarget = true

Slow down when not facing the target direction.

Incurs at a small performance overhead.

◆ wallBuffer

readonly List<Vector3> wallBuffer = new List<Vector3>()
protected

◆ wallDist

float wallDist = 1

Walls within this range will be used for avoidance.

Setting this to zero disables wall avoidance and may improve performance slightly

See also
wallForce

◆ wallForce

float wallForce = 3

Force to avoid walls with.

The agent will try to steer away from walls slightly.

See also
wallDist

Property Documentation

◆ anim

Animation anim
getset

Anim for off-mesh links.

Deprecated:
Use the onTraverseOffMeshLink event or the ... component instead. Setting this value will add a ... component

◆ ApproachingPartEndpoint

bool ApproachingPartEndpoint
get
Deprecated:
Use approachingPartEndpoint (lowercase 'a') instead

◆ approachingPartEndpoint

bool approachingPartEndpoint
get

True if approaching the last waypoint in the current part of the path.

Path parts are separated by off-mesh links.

See also
approachingPathEndpoint

◆ ApproachingPathEndpoint

bool ApproachingPathEndpoint
get
Deprecated:
Use approachingPathEndpoint (lowercase 'a') instead

◆ approachingPathEndpoint

bool approachingPathEndpoint
get

True if approaching the last waypoint of all parts in the current path.

Path parts are separated by off-mesh links.

See also
approachingPartEndpoint

◆ canMove

bool IAstarAI. canMove
getsetprivate

Enables or disables movement completely.

If you want the agent to stand still, but still react to local avoidance and use gravity: use isStopped instead.

This is also useful if you want to have full control over when the movement calculations run. Take a look at MovementUpdate

See also
canSearch
isStopped

◆ canSearch

bool IAstarAI. canSearch
getsetprivate

Enables or disables recalculating the path at regular intervals.

Setting this to false does not stop any active path requests from being calculated or stop it from continuing to follow the current path.

Note that this only disables automatic path recalculations. If you call the SearchPath() method a path will still be calculated.

See also
canMove
isStopped

◆ DistanceToNextWaypoint

float DistanceToNextWaypoint
get
Deprecated:
Use Vector3.Distance(transform.position, ai.steeringTarget) instead.

◆ hasPath

bool hasPath
get

True if this agent currently has a path that it follows.

◆ height

float IAstarAI. height
getsetprivate

Radius of the agent in world units.

This is visualized in the scene view as a yellow cylinder around the character.

Note
The Pathfinding.AILerp script doesn't really have any use of knowing the radius or the height of the character, so this property will always return 0 in that script.

◆ maxSpeed

float IAstarAI. maxSpeed
getsetprivate

Max speed in world units per second.

◆ NextWaypoint

Vector3 NextWaypoint
get

Waypoint that the agent is moving towards.

This is either a corner in the path or the end of the path.

Deprecated:
Use steeringTarget instead.

◆ PathPending

bool PathPending
get

True if a path to the target is currently being calculated.

Deprecated:
Use pathPending instead (lowercase 'p').

◆ pathPending

bool pathPending
get

True if a path is currently being calculated.

◆ position

Vector3 IAstarAI. position
getprivate

Position of the agent.

In world space.

See also
rotation

◆ radius

float IAstarAI. radius
getsetprivate

Height of the agent in world units.

This is visualized in the scene view as a yellow cylinder around the character.

This value is currently only used if an RVOController is attached to the same GameObject, otherwise it is only used for drawing nice gizmos in the scene view. However since the height value is used for some things, the radius field is always visible for consistency and easier visualization of the character. That said, it may be used for something in a future release.

Note
The Pathfinding.AILerp script doesn't really have any use of knowing the radius or the height of the character, so this property will always return 0 in that script.

◆ reachedDestination

bool reachedDestination
get

True if the ai has reached the destination.

This is a best effort calculation to see if the destination has been reached. For the AIPath/RichAI scripts, this is when the character is within endReachedDistance world units from the destination. For the AILerp script it is when the character is at the destination (±a very small margin).

This value will be updated immediately when the destination is changed (in contrast to reachedEndOfPath), however since path requests are asynchronous it will use an approximation until it sees the real path result. What this property does is to check the distance to the end of the current path, and add to that the distance from the end of the path to the destination (i.e. is assumes it is possible to move in a straight line between the end of the current path to the destination) and then checks if that total distance is less than endReachedDistance. This property is therefore only a best effort, but it will work well for almost all use cases.

Furthermore it will not report that the destination is reached if the destination is above the head of the character or more than half the height of the character below its feet (so if you have a multilevel building, it is important that you configure the height of the character correctly).

The cases which could be problematic are if an agent is standing next to a very thin wall and the destination suddenly changes to the other side of that thin wall. During the time that it takes for the path to be calculated the agent may see itself as alredy having reached the destination because the destination only moved a very small distance (the wall was thin), even though it may actually be quite a long way around the wall to the other side.

In contrast to reachedEndOfPath, this property is immediately updated when the destination is changed.

See also
#AIPath.endReachedDistance
remainingDistance
reachedEndOfPath

◆ reachedEndOfPath

bool reachedEndOfPath
get

True if the agent has reached the end of the current path.

This is the approximate distance the AI has to move to reach the end of the path it is currently traversing.

Note that setting the destination does not immediately update the path, nor is there any guarantee that the AI will actually be able to reach the destination that you set. The AI will try to get as close as possible.

It is very hard to provide a method for detecting if the AI has reached the destination that works across all different games because the destination may not even lie on the navmesh and how that is handled differs from game to game (see also the code snippet in the docs for destination).

See also
remainingDistance

◆ remainingDistance

float remainingDistance
get

Remaining distance along the current path to the end of the path.

For the RichAI movement script this may not always be precisely known, especially when far away from the destination. In those cases an approximate distance will be returned.

If the agent does not currently have a path, then positive infinity will be returned.

Note
This is the distance to the end of the path, which may or may not be at the destination. If the character cannot reach the destination it will try to move as close as possible to it.
Warning
Since path requests are asynchronous, there is a small delay between a path request being sent and this value being updated with the new calculated path.
See also
reachedDestination
reachedEndOfPath

◆ repeatedlySearchPaths

bool repeatedlySearchPaths
getset

Search for new paths repeatedly.

◆ shouldRecalculatePath

override bool shouldRecalculatePath
getprotected

◆ steeringTarget

Vector3 steeringTarget
getprotected set

Point on the path which the agent is currently moving towards.

This is usually a point a small distance ahead of the agent or the end of the path.

If the agent does not have a path at the moment, then the agent's current position will be returned.

◆ TargetPoint

Vector3 TargetPoint
get

Current waypoint that the agent is moving towards.

Deprecated:
This property has been renamed to steeringTarget

◆ TargetReached

bool TargetReached
get

True if the end of the path has been reached.

Deprecated:
When unifying the interfaces for different movement scripts, this property has been renamed to reachedEndOfPath

◆ traversingOffMeshLink

bool traversingOffMeshLink
getprotected set

◆ TraversingSpecial

bool TraversingSpecial
get
Deprecated:
This property has been renamed to 'traversingOffMeshLink'

◆ Velocity

Vector3 Velocity
get

Current velocity of the agent.

Includes velocity due to gravity.

Deprecated:
Use velocity instead (lowercase 'v').

The documentation for this class was generated from the following files: