Question by
rickifunkhacker · May 06, 2018 at 02:34 AM ·
animationanimations
Idle animation not playing after previous animation [Android game],Idle animation not working after other animations stop
My PlayerObject is switching between the run animation and sidestep animation just fine, but when i am standing still, it will continue playing the previous animation instead of the idle animation.
i have the three animator parameters set up correctly to switch between states, but i think my code is causing the Idle to not play.
The game is for android so i am using booleans to trigger movement when button is being held
// Bools to check movement state
public bool mLeft;
public bool mRight;
public bool mForward;
public bool mBackwards;
// Use this for initialization
void Start () {
Application.targetFrameRate = 60;
anim.GetComponent<Animator> ();
}
// Update is called once per frame
void Update () {
if (mLeft == true) {
transform.Translate (-mSpeed * Time.deltaTime, 0, 0);
anim.SetBool ("isRun", false);
anim.SetBool ("isSide", true);
anim.SetBool ("isIdle", false);
} else if (mRight == true) {
transform.Translate (mSpeed * Time.deltaTime, 0, 0);
anim.SetBool ("isRun", false);
anim.SetBool ("isSide", true);
anim.SetBool ("isIdle", false);
} else if (mForward == true) {
transform.Translate (0, 0, mSpeed * Time.deltaTime);
anim.SetBool ("isRun", true);
anim.SetBool ("isSide", false);
anim.SetBool ("isIdle", false);
} else if(mLeft == false || mRight == false || mForward == false) {
anim.SetBool ("isIdle", true);
}
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220612162109im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Is it possible to change Mixamo animation variables at runtime? 0 Answers
Can't play an animation from the Animator 1 Answer
How to make a smart main menu select system? 1 Answer
Simple Third Person Controller and Animation Script 0 Answers
How do I delete objects in an animation in a certain order? 1 Answer