I’m having trouble figuring this out. I can’t get the animations to change depending on where the character is moving, they just stay in their idle animation. Any help, please? I’ve been stuck on this for days.
Hey,
You can take a look at the MineBotAnimation script, included in the examples. It shows how to use the velocity as input for movement
Here is an example of how it could like like using a 2D blend tree in the animator
IAstarAI ai;
// Calculate the velocity relative to this transform's orientation
Vector3 relVelocity = transform.InverseTransformDirection(ai.velocity);
relVelocity.y = 0;
// Set the animation parameters
animator.SetFloat("forward", relVelocity.z);
animator.SetFloat("right", relVelocity.x);
If you want to make use of root motion I’d recommend taking a look at the MecanimBridge ( https://arongranberg.com/astar/docs/mecanimbridge.html )
It’s included in one of the example scenes.
Where would i do this? In a new script? If i try to do it in a new script it doesn’t recognize any of the A* asset references.
Indeed you could do this in a new script,
you’ll prob want to link the ai and animator though, either through the editor or in the Awake / Start method.
Thank you sooo much, i finally figured it out with your help. Been stuck on this forever, hahaha.