A* Pathfinding Project
4.1.0
The A* Pathfinding Project for Unity 3D
|
Advanced AI for navmesh based graphs. More...
Advanced AI for navmesh based graphs.
Public Attributes | |
bool | preciseSlowdown = true |
Use a 3rd degree equation for calculating slowdown acceleration instead of a 2nd degree. | |
bool | raycastingForGroundPlacement = false |
Public Attributes inherited from RichAI | |
float | acceleration = 5 |
Max acceleration of the agent. | |
float | endReachedDistance = 0.01f |
Max distance to the endpoint to consider it reached. | |
bool | funnelSimplification = false |
Use funnel simplification. | |
System.Func< RichSpecial, IEnumerator > | onTraverseOffMeshLink |
Called when the agent starts to traverse an off-mesh link. | |
float | rotationSpeed = 360 |
Max rotation speed of the agent. | |
float | slowdownTime = 0.5f |
How long before reaching the end of the path to start to slow down. | |
bool | slowWhenNotFacingTarget = true |
Slow down when not facing the target direction. | |
float | wallDist = 1 |
Walls within this range will be used for avoidance. | |
float | wallForce = 3 |
Force to avoid walls with. | |
Public Attributes inherited from AIBase | |
bool | canMove = true |
Enables or disables movement completely. | |
bool | canSearch = true |
Enables or disables recalculating the path at regular intervals. | |
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. | |
float | maxSpeed = 1 |
Max speed in world units per second. | |
IMovementPlane | movementPlane = GraphTransform.identityTransform |
Plane which this agent is moving in. | |
float | repathRate = 0.5f |
Determines how often the agent will search for new paths (in seconds). | |
bool | rotationIn2D = false |
If true, the forward axis of the character will be along the Y axis instead of the Z axis. | |
bool | updatePosition = true |
Determines if the character should move or if just the desired velocities should be calculated. | |
bool | updateRotation = true |
Determines if the character should rotate automatically. | |
Protected Member Functions | |
override void | Awake () |
Initializes reference variables. | |
override void | Update () |
Update is called once per frame. | |
Protected Member Functions inherited from RichAI | |
override Vector3 | ClampToNavmesh (Vector3 position, out bool positionChanged) |
Constrains the character's position to lie on the navmesh. | |
override void | MovementUpdateInternal (float deltaTime) |
Called during either Update or FixedUpdate depending on if rigidbodies are used for movement or not. | |
void | NextPart () |
Declare that the AI has completely traversed the current part. | |
override void | OnDisable () |
Called when the component is disabled. | |
override void | OnDrawGizmos () |
virtual void | OnTargetReached () |
Called when the end of the path is reached. | |
override int | OnUpgradeSerializedData (int version, bool unityThread) |
Handle serialization backwards compatibility. | |
IEnumerator | TraverseOffMeshLinkFallback (RichSpecial link) |
Fallback for traversing off-mesh links in case onTraverseOffMeshLink is not set. | |
virtual IEnumerator | TraverseSpecial (RichSpecial link) |
Traverses an off-mesh link. | |
virtual Vector3 | UpdateTarget (RichFunnel fn) |
Protected Member Functions inherited from AIBase | |
AIBase () | |
void | ApplyGravity (float deltaTime) |
Accelerates the agent downwards. | |
Vector2 | CalculateDeltaToMoveThisFrame (Vector2 position, float distanceToEndOfPath, float deltaTime) |
Calculates how far to move during a single frame. | |
virtual void | CalculatePathRequestEndpoints (out Vector3 start, out Vector3 end) |
Outputs the start point and end point of the next automatic path request. | |
void | CancelCurrentPathRequest () |
virtual void | FixedUpdate () |
Called every physics update. | |
virtual void | OnEnable () |
Called when the component is enabled. | |
Vector3 | RaycastPosition (Vector3 position, float lastElevation) |
Checks if the character is grounded and prevents ground penetration. | |
IEnumerator | RepeatTrySearchPath () |
Tries to search for a path every repathRate seconds. | |
virtual void | RotateTowards (Vector2 direction, float maxDegrees) |
Rotates towards the specified direction. | |
virtual void | Start () |
Starts searching for paths. | |
void | UpdateVelocity (Vector3 position) |
Private Member Functions | |
new Vector3 | RaycastPosition (Vector3 position, float lasty) |
bool | RotateTowards (Vector3 trotdir) |
Rotates along the Y-axis the transform towards trotdir. | |
Private Attributes | |
Vector3 | currentTargetDirection |
Vector3 | lastTargetPoint |
new 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. | |
Additional Inherited Members | |
Public Member Functions inherited from RichAI | |
override void | OnPathComplete (Path p) |
Called when a requested path has been calculated. | |
override void | SearchPath () |
Recalculate the current path. | |
override void | Teleport (Vector3 newPosition, bool clearPath=true) |
Instantly move the agent to a new position. | |
void | UpdatePath () |
Force recalculation of the current path. | |
Protected Attributes inherited from RichAI | |
bool | delayUpdatePath |
float | distanceToSteeringTarget = float.PositiveInfinity |
Distance to steeringTarget in the movement plane. | |
bool | lastCorner |
readonly List< Vector3 > | nextCorners = new List<Vector3>() |
readonly RichPath | richPath = new RichPath() |
Holds the current path that this agent is following. | |
bool | traversingSpecialPath |
readonly List< Vector3 > | wallBuffer = new List<Vector3>() |
Static Protected Attributes inherited from RichAI | |
static readonly Color | GizmoColorPath = new Color(8.0f/255, 78.0f/255, 194.0f/255) |
Properties inherited from RichAI | |
Animation | anim [get, set] |
Anim for off-mesh links. | |
bool | ApproachingPartEndpoint [get] |
bool | approachingPartEndpoint [get] |
True if approaching the last waypoint in the current part of the path. | |
bool | ApproachingPathEndpoint [get] |
bool | approachingPathEndpoint [get] |
True if approaching the last waypoint of all parts in the current path. | |
bool IAstarAI. | canMove [get, set] |
Enables or disables movement completely. | |
bool IAstarAI. | canSearch [get, set] |
Enables or disables recalculating the path at regular intervals. | |
float | DistanceToNextWaypoint [get] |
bool | hasPath [get] |
True if this agent currently has a path that it follows. | |
float IAstarAI. | maxSpeed [get, set] |
Max speed in world units per second. | |
Vector3 | NextWaypoint [get] |
Waypoint that the agent is moving towards. | |
bool | PathPending [get] |
True if a path to the target is currently being calculated. | |
bool | pathPending [get] |
True if a path is currently being calculated. | |
Vector3 IAstarAI. | position [get] |
Position of the agent. | |
float | remainingDistance [get] |
Remaining distance along the current path to the destination. | |
bool | repeatedlySearchPaths [get, set] |
Search for new paths repeatedly. | |
override bool | shouldRecalculatePath [get] |
Vector3 | steeringTarget [get, set] |
Point on the path which the agent is currently moving towards. | |
Vector3 | TargetPoint [get] |
Current waypoint that the agent is moving towards. | |
bool | TargetReached [get] |
True if the agent is within endReachedDistance units from the end of the current path. | |
bool | targetReached [get] |
True if the agent has reached the end of the current path. | |
bool | TraversingSpecial [get] |
Vector3 | Velocity [get] |
Current velocity of the agent. | |
|
protectedvirtual |
Initializes reference variables.
If you override this method you should in most cases call base.Awake () at the start of it.
Reimplemented from AIBase.
|
private |
|
private |
Rotates along the Y-axis the transform towards trotdir.
|
protectedvirtual |
Update is called once per frame.
Reimplemented from AIBase.
|
private |
|
staticprivate |
Smooth delta time to avoid getting overly affected by e.g GC.
|
private |
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 = false |
|
private |
Current velocity of the agent.
Includes eventual velocity due to gravity