A* Pathfinding Project  4.3.5
The A* Pathfinding Project for Unity 3D
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. More...
 
- 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...
 

Private Member Functions

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

Static Private Member Functions

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

Private Attributes

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

Additional Inherited Members

- Properties inherited from VersionedMonoBehaviour
int Util.IEntityIndex. EntityIndex [get, set]
 Internal entity index used by #BurstBatchHelper. More...
 
- Properties inherited from IEntityIndex
int EntityIndex [get, set]
 

Member Function Documentation

◆ Awake()

override void Awake ( )
protectedvirtual

Reimplemented from VersionedMonoBehaviour.

◆ CalculateBlendPoint()

Vector3 CalculateBlendPoint ( )
private

Calculate position of the currently grounded foot.

◆ OnAnimatorMove()

void OnAnimatorMove ( )
private

◆ RotatePointAround()

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

◆ RotateTowards()

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

◆ Update()

void Update ( )
private

Update is called once per frame.

Member Data Documentation

◆ ai

IAstarAI ai
private

Cached reference to the movement script.

◆ anim

Animator anim
private

Cached Animator component.

◆ footTransforms

Transform [] footTransforms
private

Cached reference to the left and right feet.

◆ prevFootPos

Vector3 [] prevFootPos = new Vector3[2]
private

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

◆ smoothedVelocity

Vector3 smoothedVelocity
private

◆ tr

Transform tr
private

Cached Transform component.

◆ velocitySmoothing

float velocitySmoothing = 1

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