A* Pathfinding Project  3.8.7
The A* Pathfinding Project for Unity 3D
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Properties Events Macros Groups Pages
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

void OnDisable ()
 
void OnDrawGizmos ()
 
virtual void UpdatePath ()
 Force recalculation of the current path.
 

Public Attributes

float acceleration = 5
 Max acceleration of the agent.
 
Animation anim
 
float centerOffset = 1
 
bool drawGizmos = true
 Draw gizmos in the scene view.
 
float endReachedDistance = 0.01f
 Max distance to the endpoint to consider it reached.
 
RichFunnel.FunnelSimplification funnelSimplification = RichFunnel.FunnelSimplification.None
 Mode for funnel simplification.
 
Vector3 gravity = new Vector3(0, -9.82f, 0)
 Gravity to use in case no character controller is attached.
 
LayerMask groundMask = -1
 Layer mask to use for ground placement.
 
float maxSpeed = 1
 Max speed of the agent.
 
bool preciseSlowdown = true
 Use a 3rd degree equation for calculating slowdown acceleration instead of a 2nd degree.
 
bool raycastingForGroundPlacement = true
 Raycast for ground placement (when not having a CharacterController).
 
float repathRate = 0.5f
 Delay (seconds) between path searches.
 
bool repeatedlySearchPaths = false
 Search for new paths repeatedly.
 
float rotationSpeed = 360
 Max rotation speed of the agent.
 
float slowdownTime = 0.5f
 How much time to use for slowdown in the end of the path.
 
bool slowWhenNotFacingTarget = true
 Slow down when not facing the target direction.
 
Transform target
 
float wallDist = 1
 Walls within this range will be used for avoidance.
 
float wallForce = 3
 Force to avoid walls with.
 

Static Public Attributes

static readonly Color GizmoColorPath = new Color(8.0f/255, 78.0f/255, 194.0f/255)
 
static readonly Color GizmoColorRaycast = new Color(118.0f/255, 206.0f/255, 112.0f/255)
 

Protected Member Functions

virtual void OnEnable ()
 Run at start and when reenabled.
 
virtual void OnTargetReached ()
 Called when the end of the path is reached.
 
virtual void Start ()
 Starts searching for paths.
 
virtual void Update ()
 Update is called once per frame.
 
virtual Vector3 UpdateTarget (RichFunnel fn)
 

Protected Attributes

List< Vector3 > buffer = new List<Vector3>()
 
bool canSearchPath
 
bool delayUpdatePath
 
bool lastCorner
 
float lastRepath = -9999
 
RichPath rp
 
Seeker seeker
 
Transform tr
 
bool traversingSpecialPath
 
bool waitingForPathCalc
 
List< Vector3 > wallBuffer = new List<Vector3>()
 

Properties

bool ApproachingPartEndpoint [get]
 True if approaching the last waypoint in the current path.
 
bool ApproachingPathEndpoint [get]
 True if approaching the last waypoint of all parts in the current path.
 
float DistanceToNextWaypoint [get]
 Distance to the next waypoint.
 
Vector3 TargetPoint [get]
 Current target point.
 
bool TraversingSpecial [get]
 
Vector3 Velocity [get]
 Current velocity of the agent.
 

Private Member Functions

void Awake ()
 
void NextPart ()
 Declare that the AI has completely traversed the current part.
 
void OnPathComplete (Path p)
 
Vector3 RaycastPosition (Vector3 position, float lasty)
 
bool RotateTowards (Vector3 trotdir)
 Rotates along the Y-axis the transform towards trotdir.
 
IEnumerator SearchPaths ()
 
IEnumerator TraverseSpecial (RichSpecial rs)
 

Private Attributes

CharacterController controller
 
Vector3 currentTargetDirection
 
float distanceToWaypoint = 999
 
Vector3 lastTargetPoint
 
RVOController rvoController
 
bool startHasRun
 
Vector3 velocity
 Current velocity of the agent.
 

Static Private Attributes

static float deltaTime
 Smooth delta time to avoid getting overly affected by e.g GC.
 

Member Function Documentation

void Awake ( )
private
void NextPart ( )
private

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

void OnDisable ( )
void OnDrawGizmos ( )
virtual void OnEnable ( )
protectedvirtual

Run at start and when reenabled.

Starts RepeatTrySearchPath.

See Also
Start
void OnPathComplete ( Path  p)
private
virtual void OnTargetReached ( )
protectedvirtual

Called when the end of the path is reached.

Vector3 RaycastPosition ( Vector3  position,
float  lasty 
)
private
bool RotateTowards ( Vector3  trotdir)
private

Rotates along the Y-axis the transform towards trotdir.

IEnumerator SearchPaths ( )
private
virtual void Start ( )
protectedvirtual

Starts searching for paths.

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

See Also
OnEnable
SearchPaths
IEnumerator TraverseSpecial ( RichSpecial  rs)
private
virtual void Update ( )
protectedvirtual

Update is called once per frame.

virtual void UpdatePath ( )
virtual

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).

Reimplemented in LocalSpaceRichAI.

virtual Vector3 UpdateTarget ( RichFunnel  fn)
protectedvirtual

Reimplemented in LocalSpaceRichAI.

Member Data Documentation

float acceleration = 5

Max acceleration of the agent.

World units per second per second

Animation anim
List<Vector3> buffer = new List<Vector3>()
protected
bool canSearchPath
protected
float centerOffset = 1
CharacterController controller
private
Vector3 currentTargetDirection
private
bool delayUpdatePath
protected
float deltaTime
staticprivate

Smooth delta time to avoid getting overly affected by e.g GC.

float distanceToWaypoint = 999
private
bool drawGizmos = true

Draw gizmos in the scene view.

float endReachedDistance = 0.01f

Max distance to the endpoint to consider it reached.

RichFunnel.FunnelSimplification funnelSimplification = RichFunnel.FunnelSimplification.None

Mode for 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.

readonly Color GizmoColorPath = new Color(8.0f/255, 78.0f/255, 194.0f/255)
static
readonly Color GizmoColorRaycast = new Color(118.0f/255, 206.0f/255, 112.0f/255)
static
Vector3 gravity = new Vector3(0, -9.82f, 0)

Gravity to use in case no character controller is attached.

LayerMask groundMask = -1

Layer mask to use for ground placement.

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

bool lastCorner
protected
float lastRepath = -9999
protected
Vector3 lastTargetPoint
private
float maxSpeed = 1

Max speed of the agent.

World units per second

bool preciseSlowdown = true

Use a 3rd degree equation for calculating slowdown acceleration instead of a 2nd degree.

A 3rd degree equation can also make sure that the velocity when reaching the target is roughly zero and therefore it will have a more direct stop. In contrast solving a 2nd degree equation which will just make sure the target is reached but will usually have a larger velocity when reaching the target and therefore look more "bouncy".

bool raycastingForGroundPlacement = true

Raycast for ground placement (when not having a CharacterController).

A raycast from position + up*centerOffset downwards will be done and the agent will be placed at this point.

float repathRate = 0.5f

Delay (seconds) between path searches.

bool repeatedlySearchPaths = false

Search for new paths repeatedly.

float rotationSpeed = 360

Max rotation speed of the agent.

In degrees per second.

RichPath rp
protected
RVOController rvoController
private
Seeker seeker
protected
float slowdownTime = 0.5f

How much time to use for slowdown in the end of the path.

A lower value give more abrupt stops

bool slowWhenNotFacingTarget = true

Slow down when not facing the target direction.

Incurs at a small overhead.

bool startHasRun
private
Transform target
Transform tr
protected
bool traversingSpecialPath
protected
Vector3 velocity
private

Current velocity of the agent.

Includes eventual velocity due to gravity

bool waitingForPathCalc
protected
List<Vector3> wallBuffer = new List<Vector3>()
protected
float wallDist = 1

Walls within this range will be used for avoidance.

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

float wallForce = 3

Force to avoid walls with.

The agent will try to steer away from walls slightly.

Property Documentation

bool ApproachingPartEndpoint
get

True if approaching the last waypoint in the current path.

bool ApproachingPathEndpoint
get

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

float DistanceToNextWaypoint
get

Distance to the next waypoint.

Vector3 TargetPoint
get

Current target point.

bool TraversingSpecial
get
Vector3 Velocity
get

Current velocity of the agent.

Includes eventual velocity due to gravity


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