- Home /
How to call a animation to transition to the next.
So pretty much I've been messing around with the animator component ( I'm new to Unity ) and am following this guys tutorial, he explains how to set float variables on transitions to the next animation.
My float parameters inside the animator controller are
"Walk", "Sprint", "Turn"
and if say I wanted my "Idle" animation to transition to my "Walking" animation then I would make the walk parameter greater then 0.1 and if I wanted the "Walking" animation to go back to "Idle" I would make it less then 0.1. I'm not getting any errors and my Input is not edited in anyway. I'm stumped.
Here's the script and this is attached to my male body which has the animator component.
var animator : Animator; //stores the animator component
var v : float; //vertical movements
var h : float; //horizontal movements
var sprint : float;
function Start () {
animator = GetComponent(Animator); //assigns Animator component when we start the game
}
function Update () {
v = Input.GetAxis("Vertical");
h = Input.GetAxis("Horizontal");
Sprinting();
}
function FixedUpdate () {
//set the "Walk" parameter to the v axis value
animator.SetFloat ("Walk", v);
animator.SetFloat ("Turn", h);
animator.SetFloat("Sprint", sprint);
}
function Sprinting () {
if(Input.GetKey(KeyCode.LeftShift)) {
sprint = 0.2;
}
else {
sprint = 0.0;
}
}
Your answer

Follow this Question
Related Questions
Animator Trigger Not Working 1 Answer
Playing sprint animation with vertical axis? 0 Answers
I'm confused with the animator 1 Answer
2D Animation Effects Velocity Wrong? 0 Answers
How do I animate a 2D sprite? 1 Answer