- Home /
Question by
tinashee · Nov 30, 2013 at 08:22 AM ·
animationjavascript
How to fix Animation
Now the problem that I need help fixing is that when my play goes over the speed of 0.1 the walk animation start and if it goes over 3 the run animation starts. Currently, all the animation does is run. How do I make it work.
Here's the script:
var runSpeed : float = 9000;
var moveSpeed : float = 3;
var walkingSpeed : float = 0.1;
var golemAnimator : Animator;
function Update ()
{
var input = Input.GetAxis("Horizontal");
if(input < walkingSpeed || input > walkingSpeed)
{
runSpeed = input*moveSpeed*Time.deltaTime;
transform.position.x += runSpeed;
golemAnimator.SetFloat("Running Speed", runSpeed);
}
}
Comment
Answer by AlejandroGorgal · Nov 30, 2013 at 08:29 AM
You could try setting inside an else if statement, like this:
var runSpeed:float= 10.0;
var walkSpeed:float= 1.0;
if(input >= runSpeed)
{
// run code
}
else if(input >= walkSpeed)
{
//walk code
}
else
{
// Idle
}
IF will have priority over Else If
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
animation.Play isn't working 1 Answer
Why cant i get my animation to play? 0 Answers
Climb animation is glitchy and isnt working properly 0 Answers
Why won't it run 1 Answer