- Home /
 
 
               Question by 
               titovelosa · Mar 04, 2019 at 04:35 PM · 
                animation2d gameanimator2d animation  
              
 
              Shooter 2D: Character animation only runs once
I wanted my animation to play whenever my character shoots the gun but currently the animation runs only when it fires the first time and not the others. I have the impression that it will be something very simple in the code but I have been around here and still have not found a solution. Can someone give me a hint, please?
Here is the animation part in the code:
     private Animator myAnimator;
     private bool isFire;
     private string FireAnimHash = "isFire";
 
     void Awake()
     {
         spriteRend = GetComponent<SpriteRenderer>();
     }
 
     void Start()
     {
     myAnimator = GetComponent<Animator>();
     myAnimator.enabled =true;
     myAnimator.SetBool (FireAnimHash ,isFire);
     }
 
     private void Update()
     {
     {
         AimArmAtMouse();
     }
 
         if (Input.GetButtonDown("Fire1"))
         {
           isFire = true;
           myAnimator.SetBool (FireAnimHash ,isFire);
         }
 
 
              
               Comment
              
 
               
               
               Best Answer 
              
 
              Answer by titovelosa · Mar 07, 2019 at 03:38 PM
If anyone needs to know...i resolve the problem using Trigger instead of Bool...
Your answer