- Home /
How to script mecanim turning animations?
I already have mecanim blend trees setup with my ai and they are working great except for one thing. I cannot figure out how to play the turning animations through scripting. I have tried using the stealth tutorial but I cannot figure out exactly how it works. I am using the parameters move speed and angular speed in my blend tree. Using the move speed was pretty straight forward but how would I change the angular speed parameter to update the blended animations? Here is the script I use to change the forward speed atm.
var rexAnimator : Animator;
var currentSpeed = 0f; // movement speed variable.
var lgCarnAction : LgCarnActionManager;
private var lastPos : Vector3;
function Start()
{
rexAnimator = GetComponent(Animator);
}
function Update()
{
var currentMovement = transform.position - lastPos;
currentSpeed = currentMovement.magnitude / Time.deltaTime;
lastPos = transform.position;
rexAnimator.SetFloat("MoveSpeed",currentSpeed);
}
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220613161259im_/https://answers.unity.com/themes/thub/images/avi.jpg)