A* Pathfinding Project  4.1.2
The A* Pathfinding Project for Unity 3D
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Properties Events Macros Groups Pages
MecanimBridge Class Reference

Example of how to use Mecanim with the included movement scripts. More...

Detailed Description

Example of how to use Mecanim with the included movement scripts.

This script will use Mecanim to apply root motion to move the character instead of allowing the movement script to do the movement.

It assumes that the Mecanim controller uses 3 input variables

  • InputMagnitude which is simply 1 when the character should be moving and 0 when it should stop.
  • X which is component of the desired movement direction along the left/right axis.
  • Y which is component of the desired movement direction along the forward/backward axis.

It works with AIPath and RichAI.

See Also
Pathfinding.IAstarAI
Pathfinding.AIPath
Pathfinding.RichAI

Public Attributes

float velocitySmoothing = 1
 

Protected Member Functions

override void Awake ()
 
virtual Quaternion RotateTowards (Vector3 direction, float maxDegrees)
 Calculates a rotation closer to the desired direction.
 
- Protected Member Functions inherited from VersionedMonoBehaviour
virtual int OnUpgradeSerializedData (int version, bool unityThread)
 Handle serialization backwards compatibility.
 

Private Member Functions

Vector3 CalculateBlendPoint ()
 Calculate position of the currently grounded foot.
 
void OnAnimatorMove ()
 
void Update ()
 Update is called once per frame.
 

Static Private Member Functions

static Vector3 RotatePointAround (Vector3 point, Vector3 around, Quaternion rotation)
 

Private Attributes

IAstarAI ai
 Cached reference to the movement script.
 
Animator anim
 Cached Animator component.
 
Transform[] footTransforms
 Cached reference to the left and right feet.
 
Vector3[] prevFootPos = new Vector3[2]
 Position of the left and right feet during the previous frame.
 
Vector3 smoothedVelocity
 
Transform tr
 Cached Transform component.
 

Additional Inherited Members

- Public Member Functions inherited from IVersionedMonoBehaviourInternal
int OnUpgradeSerializedData (int version, bool unityThread)
 

Member Function Documentation

override void Awake ( )
protectedvirtual

Reimplemented from VersionedMonoBehaviour.

Vector3 CalculateBlendPoint ( )
private

Calculate position of the currently grounded foot.

void OnAnimatorMove ( )
private
static Vector3 RotatePointAround ( Vector3  point,
Vector3  around,
Quaternion  rotation 
)
staticprivate
virtual Quaternion RotateTowards ( Vector3  direction,
float  maxDegrees 
)
protectedvirtual

Calculates a rotation closer to the desired direction.

Parameters
directionDirection in the movement plane to rotate toward.
maxDegreesMaximum number of degrees to rotate this frame.
Returns
The new rotation for the character
void Update ( )
private

Update is called once per frame.

Member Data Documentation

IAstarAI ai
private

Cached reference to the movement script.

Animator anim
private

Cached Animator component.

Transform [] footTransforms
private

Cached reference to the left and right feet.

Vector3 [] prevFootPos = new Vector3[2]
private

Position of the left and right feet during the previous frame.

Vector3 smoothedVelocity
private
Transform tr
private

Cached Transform component.

float velocitySmoothing = 1

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