- Home /
 
               Question by 
               gellihorvath · Jul 27, 2020 at 09:51 AM · 
                animation2dunity 2dgunroot motion  
              
 
              My animation barely moves with root motion.
Hi Guys! Right now I am working on a 2d shooter game, where the gun follows the mouse rotation and I made a "recoil" animation for my gun. It's plays every time when a shot fired, but unfortunately if I turn off the root motion option the "recoil" animation works perefectly but the "idle" animation doesn't rotate with my mouse. If I turn on the root motion, my gun rotate perfectly with my mouse, but the "recoil" animation just barely moves the gun, not as much as I animated it. I know it's very confusing but I hope someone can help me. Thank you Guys!
               Comment
              
 
               
              Answer by Headrush95 · Jul 30, 2020 at 12:01 AM
have you tried
 public Animator anim;
 
 void Start()
 {
 anim = Getcomponent<animator>():
 }
 
 void Update(){
 
 if (anim.GetCurrentAnimatorStateInfo(0).IsName("Fire"))
 {
 anim.applyRootMotion = false;
 }else 
 {
 anim.applyRootMotion = true;
 }
 }
 
Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                