Shooting animation and bullet generation issue
Hey guys, I'm a new in Unity and making my first 2D game. I seen several topics on this forum in this issue, but I didn't found the solution.
So I have a lovely shooting animation and the bullet generation. My problem, I have to generate the bullet somewhere at the middle of the animation, but the character shoots the bullet and the animation at the same time, which killing the UX :)
I attached an image, about the issue, this is the moment, when the bullet should be initialized, but as you can see it's already on it's way.
Please find my code: The GameManager update method calls the attackEnemy function:
 public void Awake(){    
         animator = GetComponent ();
         animator.SetTrigger ("enemyIdle");
     }
  
 
 
     //if the enemy pass this point, they stop shooting, and just go off the scren
     private float shootingStopLimit = -6f;
  
     public  override void  attackPlayer(){
         //animator.SetTrigger ("enemyIdle");
         if (!isAttacking && gameObject.transform.position.y > shootingStopLimit) {
             isAttacking = true;
             animator.SetTrigger("enemyShoot");
             StartCoroutine(doWait());
             gameObject.GetComponentInChildren ().fireBullet ();
             StartCoroutine (Reload ());
         }
     }
    
     private IEnumerator doWait(){
         yield return new WaitForSeconds(5);
     }
 
     private IEnumerator Reload(){
         animator.SetTrigger ("enemyIdle");
 
         int reloadTime = Random.Range (4,7);
         yield return new WaitForSeconds(reloadTime);
     
         isAttacking = false;
     }......
 
               My questions: - How can I sync the animation and the bullet generation ? - Why not the doWait() works ? :) - Is it okay to call the attackPlayer method from the GameManager update ? - The enemies are flynig from the right side of the screen to the left, when they reach the most right side of the screen, they became visible to the user. I don't know why, but they to a shooting animation (no bullet generation happen )first, only after it they do the idle. Any idea why ?
Thanks, 
Your answer