2017-01-22 15 views
1

アニメーションを再生するときに、ループ再生(リプレイ)し、動きアニメーション(ウォーキング、ランニング、ジャンプ)に適しています。再生時にアニメーションを停止する(アタック)

しかし、PICのように私の場合、それは奇妙な効果を引き起こしている:今

errorloop

私はクリックして、私が何をしたいボタンを押したときには、とは異なりthe character should take his arm up and then keep itは何度も何度もそれを取っていることです私がボタンから指を離さない限り。

Bcozその攻撃のアニメーション thatsなぜ私はそれが欲しくない!次のように

攻撃スクリプトとアニメーションの呼び出しは次のとおりです。

public void LaserAttack(){ 
     isAttacking = true; 
     if (robotLeft == true&&isLaserLeft==false) { 

      //Debug.Log (firep.position.x); 

      //Instantiate (leftLaser, firep.position*1.29f, Quaternion.identity); 

      StartCoroutine(DelayMethodLeftInstantiate()); 

     } 

     if (robotRight == true&&isLaserLeft==false) { 

      StartCoroutine( DelayMethodRightInstantiate()); 

      //Instantiate (RightLaser, firep.position, Quaternion.identity); 
     } 
     anim.SetBool ("isAttack", isAttacking); 
     isLaserLeft = true; 

    } 

    public void LaserAttackEnd(){ 
     isAttacking = false; 

     anim.SetBool ("isAttack", isAttacking); 
     isLaserLeft = false; 
} 

次のように私はタッチボタンで攻撃アニメーションを呼び出しています! enter image description here

これを実現する方法は?

答えて

3

ソリューションは、我々は別のアニメーションだけで、攻撃アニメーションの後に再生されるようにしたいと、まだをプレイヤー攻撃の新しいアニメーションを作成し、coroutine

を使用することであり、それは達成するために、アニメーション(攻撃) の両方を停止し終了したとき所望の出力。 enter image description here

とコードで:

public void LaserAttack(){ 
     isAttacking = true; 
     StartCoroutine (AttackStillCoroutine()); 

     if (robotLeft == true&&isLaserLeft==false) { 

      //Debug.Log (firep.position.x); 

      //Instantiate (leftLaser, firep.position*1.29f, Quaternion.identity); 

      StartCoroutine(DelayMethodLeftInstantiate()); 

     } 

     if (robotRight == true&&isLaserLeft==false) { 

      StartCoroutine( DelayMethodRightInstantiate()); 

      //Instantiate (RightLaser, firep.position, Quaternion.identity); 
     } 
     anim.SetBool ("isAttack", isAttacking); 
     isLaserLeft = true; 

    } 

    public void LaserAttackEnd(){ 
     isAttacking = false; 
     attackStill = false; 
     anim.SetBool ("isAttackStill",attackStill); 
     anim.SetBool ("isAttack", isAttacking); 
     isLaserLeft = false; 

    } 

次のようにコルーチンがある:

IEnumerator AttackStillCoroutine(){ 

      yield return new WaitForSeconds (1); 
      attackStill = true; 
      anim.SetBool ("isAttackStill",attackStill); 

     } 
ニースとシンプルな

...

はアニメーターにPIC内の1つのハイライト表示さ

関連する問題