- Home /
 
               Question by 
               Riskabarjoin · Oct 19, 2018 at 10:49 AM · 
                c#animationscripting problemcoroutine  
              
 
              Issue involving coroutines and animation
I am currently making an combo system in which the player is locked in place while the animation is playing . It's using a coroutine that locks the player while the animation is playing. Here 's my combo code:
     if (Input.GetKeyDown("joystick button 1") )
     {
         if ((LastAttack - Time.time) > 0.5f || AttackCounter == 0)
         {
             anim.SetTrigger("Attack1");
             // length of the animation 'attack 1'
             float timeOfAnimation = GetComponent<Animator>().runtimeAnimatorController.animationClips[7].length;
             StartCoroutine(STOP(timeOfAnimation, 0.3f));
             AttackCounter = 1;
         }
         else if (AttackCounter == 1)
         {    
             anim.SetTrigger("Attack2");
             // length of the animation 'attack2'
             float timeOfAnimation = GetComponent<Animator>().runtimeAnimatorController.animationClips[8].length;
             StartCoroutine(STOP(timeOfAnimation,0f));
             AttackCounter = 0;
         }
         LastAttack = Time.time;
     }
Now here's my coroutine "STOP":
 public IEnumerator STOP(float duration,float offset)
 {
     FreezePlayer();
     FreezeRotation();
         yield return new WaitForSeconds((duration-offset));
         unFreezePlayer();
         unFreezeRotation();
 }
 The player is locked in place during the first attack and first half of the second attack.
 Changing the values of the duration and the offset when calling the coroutine "STOP" for the second attack has no effect.
 It's the first time i'm using coroutines
 Any thoughts ? 
               Comment
              
 
               
              Your answer
 
 
             Follow this Question
Related Questions
Flip between 2 states constantly C#? 1 Answer
the player is not shooting 1 Answer
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                