A* Pathfinding Project  4.2.0
The A* Pathfinding Project for Unity 3D
MineBotAnimation Class Reference

Animation helper specifically made for the spider robot in the example scenes. More...

Detailed Description

Animation helper specifically made for the spider robot in the example scenes.

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.
A movement script (e.g AIPath) must also be attached to the same GameObject to actually move the unit.

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.

Public Attributes

Animation anim
 Animation component. More...
 
float animationSpeed = 0.2F
 Speed relative to velocity with which to play animations. More...
 
GameObject endOfPathEffect
 Effect which will be instantiated when end of path is reached. More...
 
float sleepVelocity = 0.4F
 Minimum velocity for moving. More...
 

Protected Member Functions

override void Awake ()
 
void Update ()
 
- Protected Member Functions inherited from VersionedMonoBehaviour
virtual int OnUpgradeSerializedData (int version, bool unityThread)
 Handle serialization backwards compatibility. More...
 
virtual void Reset ()
 Handle serialization backwards compatibility. More...
 

Protected Attributes

Vector3 lastTarget
 Point for the last spawn of endOfPathEffect. More...
 

Private Member Functions

void OnTargetReached ()
 Called when the end of path has been reached. More...
 
void Start ()
 

Private Attributes

IAstarAI ai
 
bool isAtDestination
 
Transform tr
 

Additional Inherited Members

Member Function Documentation

◆ Awake()

override void Awake ( )
protectedvirtual

Reimplemented from VersionedMonoBehaviour.

◆ OnTargetReached()

void OnTargetReached ( )
private

Called when the end of path has been reached.

An effect (endOfPathEffect) is spawned when this function is called However, since paths are recalculated quite often, we only spawn the effect when the current position is some distance away from the previous spawn-point

◆ Start()

void Start ( )
private

◆ Update()

void Update ( )
protected

Member Data Documentation

◆ ai

IAstarAI ai
private

◆ anim

Animation anim

Animation component.

Should hold animations "awake" and "forward"

◆ animationSpeed

float animationSpeed = 0.2F

Speed relative to velocity with which to play animations.

◆ endOfPathEffect

GameObject endOfPathEffect

Effect which will be instantiated when end of path is reached.

See also
OnTargetReached

◆ isAtDestination

bool isAtDestination
private

◆ lastTarget

Vector3 lastTarget
protected

Point for the last spawn of endOfPathEffect.

◆ sleepVelocity

float sleepVelocity = 0.4F

Minimum velocity for moving.

◆ tr

Transform tr
private

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