- Home /
 
How to move player after animation
Hello, I'm trying to move a player with an animation that makes him jump forward. The problem is when I press the key to run the animation, the player goes forward and then, when the animation ends, the player goes back to the start point.
I know the solution is to move the player position when the animation runs, but the problem is that I can't do it because in FixedUpdate I get the position through Input.GetAxis().

      static Animator anim;
      private float Speed = 2.0f; 
      public float rotationSpeed = 150.0f; 
      public float WalkSpeed = 2.0f; 
      public float RunSpeed = 4.0f;
 
      void Start () {
           anim = GetComponent<Animator>();
      }
     
      void FixedUpdate () {
           float translation = Input.GetAxis("Vertical") * Speed;
           float rotation = Input.GetAxis("Horizontal") *  rotationSpeed;
         
           translation *= Time.deltaTime;
           rotation *= Time.deltaTime;
 
           transform.Translate(0, 0, translation);
           transform.Rotate(0, rotation, 0);
 
           if (Input.GetMouseButtonDown(0))
           {
                anim.SetBool("isIdle", false);
                anim.SetBool("isTurning", false);
                anim.SetBool("isWalking", false);
                anim.SetBool("isRunning", false);
                anim.SetTrigger("attack");
           }
      }
 
              Answer by TelmoF · Feb 15, 2018 at 09:36 PM
After a lot of work and trying different things I found the solution. I switch the animation type to Humanoid and on every animation I change the animation defenition to Copy from other avatar and then I selected the main player.
In Animations tag I had always an error saying: "Imported file 'standing death forward 01' conversion failed: Required human bone 'Hips' not found. To solve that error I just had to click on Update button on Rig tab. 
 Finally, I checked the Root Transform Rotation and the Root Transform Position (Y) and it worked really well. 
Answer by dev-waqas · Jan 26, 2018 at 04:48 AM
You have to enable root motion for your animator, 
Thanks for the reply but I've already tried and it didn't work.
@TelmoF If apply root motion doesnt work try to edit your animation. There should be settings for moving root along XY.
Your answer