AI controller specifically made for the spider robot.
The spider robot (or mine-bot) which has been copied from the Unity Example Project can have this script attached to be able to pathfind around with animations working properly.
This script should be attached to a parent GameObject however since the original bot has Z+ as up. This component requires Z+ to be forward and Y+ to be up.
It overrides the AIPath class, see that class's documentation for more information on most variables.
Animation is handled by this component. The Animation component refered to in anim should have animations named "awake" and "forward". The forward animation will have it's speed modified by the velocity and scaled by animationSpeed to adjust it to look good. The awake animation will only be sampled at the end frame and will not play.
When the end of path is reached, if the endOfPathEffect is not null, it will be instantiated at the current position. However a check will be done so that it won't spawn effects too close to the previous spawn-point.
|
override void | OnTargetReached () |
| Called when the end of path has been reached. More...
|
|
new void | Start () |
| Starts searching for paths. More...
|
|
Vector3 | CalculateVelocity (Vector3 position) |
| Current desired velocity of the agent (excluding physics and local avoidance but it includes gravity). More...
|
|
override void | OnPathComplete (Path newPath) |
| Called when a requested path has been calculated. More...
|
|
override void | Teleport (Vector3 newPosition, bool clearPath=true) |
| Instantly move the agent to a new position. More...
|
|
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...
|
|
virtual void | SearchPath () |
| Recalculate the current path. More...
|
|
Quaternion | SimulateRotationTowards (Vector3 direction, float maxDegrees) |
| Simulates rotating the agent towards the specified direction and returns the new rotation. More...
|
|
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 | SearchPath () |
| Recalculate the current path. More...
|
|
|
override void | Update () |
| Called every frame. More...
|
|
virtual void | CalculateNextRotation (float slowdown, out Quaternion nextRotation) |
|
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...
|
|
override void | OnDisable () |
|
override int | OnUpgradeSerializedData (int version, bool unityThread) |
| Handle serialization backwards compatibility. More...
|
|
| 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 Vector3 | ClampToNavmesh (Vector3 position, out bool positionChanged) |
| Constrains the character's position to lie on the navmesh. More...
|
|
virtual void | FindComponents () |
|
virtual void | FixedUpdate () |
| Called every physics update. More...
|
|
virtual void | OnDrawGizmos () |
|
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...
|
|
IEnumerator | RepeatTrySearchPath () |
| Tries to search for a path every repathRate seconds. More...
|
|
Quaternion | SimulateRotationTowards (Vector2 direction, float maxDegrees) |
| Simulates rotating the agent towards the specified direction and returns the new rotation. More...
|
|
void | UpdateVelocity () |
|
virtual void | Awake () |
|
|
static readonly Color | GizmoColorRaycast = new Color(118.0f/255, 206.0f/255, 112.0f/255) |
|
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...
|
|
bool | hasPath [get] |
| True if this agent currently has a path that it follows. More...
|
|
float IAstarAI. | maxSpeed [get, set] |
| Max speed in world units per second. More...
|
|
bool | pathPending [get] |
| True if a path is currently being calculated. More...
|
|
bool | reachedEndOfPath [get, protected set] |
| 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...
|
|
float | speed [get, set] |
| Maximum speed in world units per second. More...
|
|
Vector3 | steeringTarget [get] |
| Point on the path which the agent is currently moving towards. More...
|
|
Vector3 | targetDirection [get] |
| Direction that the agent wants to move in (excluding physics and local avoidance). More...
|
|
bool | TargetReached [get] |
| True if the end of the path has been reached. More...
|
|
float | turningSpeed [get, set] |
| Rotation speed. 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...
|
|
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...
|
|
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...
|
|
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...
|
|
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...
|
|