Class AIBase Extends VersionedMonoBehaviour

Public Abstract

Base class for AIPath and RichAI.

This class holds various methods and fields that are common to both AIPath and RichAI.

See

Pathfinding.AIPath

Pathfinding.RichAI

Pathfinding.IAstarAI (all movement scripts implement this interface)

Public Methods

FinalizeMovement (nextPosition, nextRotation)

Moves the agent to a position.

Looks for any attached components like RVOController and CharacterController etc.

Position of the base of the character.

Move (deltaPosition)

Move the agent.

MovementUpdate (deltaTime, nextPosition, nextRotation)

Calculate how the character wants to move during this frame.

Recalculate the current path.

SetPath (path, updateDestinationFromPath=true)

Make the AI follow the specified path.

SimulateRotationTowards (direction, ...)

Simulates rotating the agent towards the specified direction and returns the new rotation.

Teleport (newPosition, clearPath=true)

Instantly move the agent to a new position.

Public Variables

autoRepath

Determines how the agent recalculates its path automatically.

Public
canMove

Enables or disables movement completely.

Public
desiredVelocity

Velocity that this agent wants to move with.

Public
desiredVelocityWithoutLocalAvoidance

Velocity that this agent wants to move with before taking local avoidance into account.

Public
destination

Position in the world that this agent should move to.

Public
enableRotation

If true, the AI will rotate to face the movement direction.

Public
endOfPath

End point of path the agent is currently following.

Public Abstract
endReachedDistance

Distance to the end point to consider the end of path to be reached.

Public
gravity

Gravity to use.

Public
groundMask

Layer mask to use for ground placement.

Public
height

Height of the agent in world units.

Public
isStopped

Gets or sets if the agent should stop moving.

Public
maxSpeed

Max speed in world units per second.

Public
movementPlane

Plane which this agent is moving in.

Public
onSearchPath

Called when the agent recalculates its path.

Public
orientation

Determines which direction the agent moves in.

Public
position

Position of the agent.

Public
radius

Radius of the agent in world units.

Public
reachedDestination

True if the ai has reached the destination.

Public Abstract
rotation

Rotation of the agent.

Public
rvoDensityBehavior

Controls if the agent slows down to a stop if the area around the destination is crowded.

Public
updatePosition

Determines if the character's position should be coupled to the Transform's position.

Public
updateRotation

Determines if the character's rotation should be coupled to the Transform's rotation.

Public
velocity

Actual velocity that the agent is moving with.

Public
whenCloseToDestination

What to do when within endReachedDistance units from the destination.

Public

Public Static Variables

ShapeGizmoColor
Public Static Readonly

Private/Protected Members

ApplyGravity (deltaTime)

Accelerates the agent downwards.

Awake ()
CalculateDeltaToMoveThisFrame (position, distanceToEndOfPath, deltaTime)

Calculates how far to move during a single frame.

Outputs the start point and end point of the next automatic path request.

ClampToNavmesh (position, positionChanged)

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

Clears the current path of the agent.

FinalizePosition (nextPosition)
FinalizeRotation (nextRotation)
Init ()
MovementUpdateInternal (deltaTime, nextPosition, nextRotation)

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

Called when the component is enabled.

OnPathComplete (newPath)

Called when a requested path has been calculated.

OnUpdate (...)

Called every frame.

OnUpgradeSerializedData (migrations, unityThread)

RaycastPosition (position, lastElevation)

Checks if the character is grounded and prevents ground penetration.

Reset ()

Handle serialization backwards compatibility.

Start ()

Starts searching for paths.

UpgradeSerializedData (isUnityThread)
accumulatedMovementDelta

Accumulated movement deltas from the Move method.

Protected
canSearchCompability
Private
controller

Cached CharacterController component.

Protected
destinationBackingField

Backing field for destination.

Private
lastDeltaPosition

Amount which the character wants or tried to move with during the last frame.

Protected
lastDeltaTime

Delta time used for movement during the last frame.

Protected
lastRaycastHit

Hit info from the last raycast done for ground placement.

Protected
lastRepath

Time when the last path request was started.

Protected
onPathComplete

Cached delegate for the OnPathComplete method.

Protected
prevPosition1

Position of the character at the end of the last frame.

Protected
prevPosition2

Position of the character at the end of the frame before the last frame.

Protected
repathRateCompatibility
Private
rigid

Cached Rigidbody component.

Protected
rigid2D

Cached Rigidbody component.

Protected
rvoController

Cached RVOController component.

Protected
seeker

Cached Seeker component.

Protected
shouldRecalculatePath

True if the path should be automatically recalculated as soon as possible.

Protected
simulatedPosition

Position of the agent.

Protected
simulatedRotation

Rotation of the agent.

Protected
startHasRun

True if the Start method has been executed.

Protected
tr

Cached Transform component.

Protected
usingGravity

Indicates if gravity is used during this frame.

Protected
velocity2D

Current desired velocity of the agent (does not include local avoidance and physics).

Protected
verticalVelocity

Velocity due to gravity.

Protected
waitingForPathCalculation

Only when the previous path has been calculated should the script consider searching for a new path.

Protected

Deprecated Members

canSearch

Enables or disables recalculating the path at regular intervals.

Public
repathRate

Determines how often the agent will search for new paths (in seconds).

Public