- Home /
Overwriting animation parameters play animation while other is already playing?
So im totally aware of animation layers but that is not what im looking for. See when i control my animator parameters i use else if statements and that is probably not how you are suppose to do it. But anyway if i have different animations asigned to different keys and press ex. W and D at the same time the wrong animation plays. I want it so if i press W first then D i want the D animation to play. How does one achive this? Here is my weird code:
if (Input.GetKey (KeyCode.W)) {
//Forward
moving = true;
canFire = false;
anim.SetInteger ("RunIndex", 1);
} else if (Input.GetKey (KeyCode.S)) {
//back
moving = true;
canFire = false;
anim.SetInteger ("RunIndex", 2);
} else if (Input.GetKey (KeyCode.A)) {
//Run left
moving = true;
canFire = false;
anim.SetInteger ("RunIndex", 4);
} else if (Input.GetKey (KeyCode.D)) {
////Run right
moving = true;
canFire = false;
anim.SetInteger ("RunIndex", 3);
}else {
anim.SetInteger ("RunIndex", 0);
moving = false;
canFire = true;
//idle
}
Your answer
Follow this Question
Related Questions
Animator Controller 2D RPG Best Practices 0 Answers
Animtion looping if joystick is held 0 Answers
Is there a new retargetting system for the animation in 5.5? 1 Answer
Can I play an animation with only 1 image for a duration? 0 Answers
[Solvedf]Animator is not playing an AnimatorController 2 Answers