animation stuck

Updated on March 24, 2018 in [A] Animation
Share on Facebook0Tweet about this on TwitterShare on Google+0Share on Reddit0
0 on March 24, 2018

hai… i want to ask about animator controller… so i have 3 animation : idle, run, and jump…  and i have animation script to make it move… here the script

private Animator anim;
 private bool RightDir = true;
 private Transform Arah;
// Use this for initialization
 void Start () {
 RightDir = true;
 anim = GetComponent<Animator> ();
 Arah = GetComponent<Transform> ();
 }
 // Update is called once per frame
 void Update () {
 if(Input.GetKeyDown (KeyCode.RightArrow) && RightDir == false) {
 Arah.Rotate(new Vector3(0, 180,0));
 RightDir = true;
 }else if(Input.GetKeyDown (KeyCode.LeftArrow) && RightDir == true) {
 Arah.Rotate(new Vector3(0, 180,0));
 RightDir = false;
 }
if (SceneManager.GetActiveScene ().name == "SceneAtom") {
 if (Input.GetKeyDown (KeyCode.RightArrow) || Input.GetKeyDown (KeyCode.LeftArrow)) {
 anim.SetTrigger ("run");
 }else if(Input.GetKeyUp (KeyCode.RightArrow) || Input.GetKeyUp (KeyCode.LeftArrow)) {
 anim.SetTrigger ("idle");
 }
if (Input.GetKeyDown (KeyCode.Space)) {
 anim.SetTrigger ("jump");
 }
 }
 }

 

the problem i get is when i pressing left and right button quickly, sometime the trigger will stuck on run, is it anyone know what should i do about it?

  • Liked by
Reply