A* Pathfinding Project  4.0.5
The A* Pathfinding Project for Unity 3D
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Properties Events Macros Groups Pages
AIBase Class Referenceabstract

Base class for AIPath and RichAI. More...

Detailed Description

Base class for AIPath and RichAI.

Public Attributes

float centerOffset = 1
 Offset along the Y coordinate for the ground raycast start position.
 
Vector3 gravity = new Vector3(float.NaN, float.NaN, float.NaN)
 Gravity to use.
 
LayerMask groundMask = -1
 Layer mask to use for ground placement.
 

Protected Member Functions

void ApplyGravity (float deltaTime)
 
override void Awake ()
 Initializes reference variables.
 
Vector2 CalculateDeltaToMoveThisFrame (Vector2 position, float distanceToEndOfPath, float deltaTime)
 
virtual Vector3 ClampToNavmesh (Vector3 position)
 Constrains the character's position to lie on the navmesh.
 
virtual void FixedUpdate ()
 Called every physics update.
 
void Move (Vector3 position3D, Vector3 deltaPosition)
 
abstract void MovementUpdate (float deltaTime)
 Called during either Update or FixedUpdate depending on if rigidbodies are used for movement or not.
 
virtual void OnDrawGizmos ()
 
Vector3 RaycastPosition (Vector3 position, float lastElevation)
 Find the world position of the ground below the character.
 
virtual void RotateTowards (Vector2 direction, float maxDegrees)
 Rotates in the specified direction.
 
virtual void Update ()
 Called every frame.
 
- Protected Member Functions inherited from VersionedMonoBehaviour
virtual int OnUpgradeSerializedData (int version)
 Handle serialization backwards compatibility.
 

Protected Attributes

CharacterController controller
 Cached CharacterController component.
 
IMovementPlane movementPlane = GraphTransform.identityTransform
 
Rigidbody rigid
 Cached Rigidbody component.
 
Rigidbody2D rigid2D
 Cached Rigidbody component.
 
RVOController rvoController
 Cached RVOController component.
 
Seeker seeker
 Cached Seeker component.
 
Transform tr
 Cached Transform component.
 
Vector2 velocity2D
 Current desired velocity of the agent.
 
float verticalVelocity
 Velocity due to gravity.
 

Static Protected Attributes

static readonly Color GizmoColorRaycast = new Color(118.0f/255, 206.0f/255, 112.0f/255)
 

Properties

bool usingGravity [get, set]
 Indicates if gravity is used during this frame.
 

Member Function Documentation

void ApplyGravity ( float  deltaTime)
protected
override void Awake ( )
protectedvirtual

Initializes reference variables.

If you override this function you should in most cases call base.Awake () at the start of it.

Reimplemented from VersionedMonoBehaviour.

Reimplemented in LegacyAIPath, and LegacyRichAI.

Vector2 CalculateDeltaToMoveThisFrame ( Vector2  position,
float  distanceToEndOfPath,
float  deltaTime 
)
protected
virtual Vector3 ClampToNavmesh ( Vector3  position)
protectedvirtual

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

Not all movement scripts have support for this.

Reimplemented in RichAI.

virtual void FixedUpdate ( )
protectedvirtual

Called every physics update.

If rigidbodies are used then all movement happens here

void Move ( Vector3  position3D,
Vector3  deltaPosition 
)
protected
abstract void MovementUpdate ( float  deltaTime)
protectedpure virtual

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

Implemented in RichAI, and AIPath.

virtual void OnDrawGizmos ( )
protectedvirtual

Reimplemented in RichAI.

Vector3 RaycastPosition ( Vector3  position,
float  lastElevation 
)
protected

Find the world position of the ground below the character.

virtual void RotateTowards ( Vector2  direction,
float  maxDegrees 
)
protectedvirtual

Rotates in the specified direction.

Rotates around the Y-axis.

See Also
turningSpeed
virtual void Update ( )
protectedvirtual

Called every frame.

If no rigidbodies are used then all movement happens here

Reimplemented in LegacyAIPath, MineBotAI, LocalSpaceRichAI, and LegacyRichAI.

Member Data Documentation

float centerOffset = 1

Offset along the Y coordinate for the ground raycast start position.

Normally the pivot of the character is at the character's feet, but you usually want to fire the raycast from the character's center, so this value should be half of the character's height.

A green gizmo line will be drawn upwards from the pivot point of the character to indicate where the raycast will start.

See Also
gravity
CharacterController controller
protected

Cached CharacterController component.

readonly Color GizmoColorRaycast = new Color(118.0f/255, 206.0f/255, 112.0f/255)
staticprotected
Vector3 gravity = new Vector3(float.NaN, float.NaN, float.NaN)

Gravity to use.

If set to (NaN,NaN,NaN) then Physics.Gravity (configured in the Unity project settings) will be used. If set to (0,0,0) then no gravity will be used and no raycast to check for ground penetration will be performed.

LayerMask groundMask = -1

Layer mask to use for ground placement.

Make sure this does not include the layer of any colliders attached to this gameobject.

See Also
gravity
https://docs.unity3d.com/Manual/Layers.html
Rigidbody rigid
protected

Cached Rigidbody component.

Rigidbody2D rigid2D
protected

Cached Rigidbody component.

RVOController rvoController
protected

Cached RVOController component.

Seeker seeker
protected

Cached Seeker component.

Transform tr
protected

Cached Transform component.

Vector2 velocity2D
protected

Current desired velocity of the agent.

Lies in the movement plane.

float verticalVelocity
protected

Velocity due to gravity.

Perpendicular to the movement plane.

Property Documentation

bool usingGravity
getsetprotected

Indicates if gravity is used during this frame.


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