Search Unity

Changing Position of Character while rolling animation

Discussion in 'Animation' started by aviralgoel, Jun 22, 2019.

  1. aviralgoel

    aviralgoel

    Joined:
    Jul 12, 2017
    Posts:
    4
    Hello,
    I have my player character animated model (downloaded from Mixamo, with roll forward animation).
    I am able to play the roll animation whenever space key is pressed using trigger parameter.
    Here is my code
    Code (CSharp):
    1. using UnityEngine;
    2.  
    3. public class PlayerMovement : MonoBehaviour
    4. {
    5.     private Animator anim;
    6.     private Rigidbody rb;
    7.  
    8.     // Start is called before the first frame update
    9.     void Start()
    10.     {
    11.         anim = GetComponent<Animator>();
    12.         rb = GetComponent<Rigidbody>();
    13.     }
    14.     private void Update()
    15.     {
    16.         if (Input.GetKeyDown(KeyCode.Space))
    17.             anim.SetTrigger("Roll");
    18.     }
    19. }
    20.  
    But, right after the animation is placed, my player comes back to it's original position.
    (I know, its because I am just playing the animation and not changing its transform).
    But how do I change it's transform, so that the player actually appears to be rolling forward.
     
  2. aviralgoel

    aviralgoel

    Joined:
    Jul 12, 2017
    Posts:
    4
  3. aviralgoel

    aviralgoel

    Joined:
    Jul 12, 2017
    Posts:
    4
    I tried checking Apply Root Motion on the Animator and selected Hips as Root Node in the animation settings,
    the character changes it's tranform but no matter which bone I select as root, it is always at some weird rotation.
    https://gyazo.com/86daf283b36a63d48ffd9f04f404aac5
     
  4. Kybernetik

    Kybernetik

    Joined:
    Jan 3, 2013
    Posts:
    2,570
    I'm no expert on Root Motion, but this sort of thing usually requires some fiddling around in the animation's import settings like Root Transform Rotation.
     
  5. Fedora_Dev

    Fedora_Dev

    Joined:
    Oct 28, 2016
    Posts:
    35
    what does the import settings on the model look like? i would need to see the rig tab, and the import settings for the animation file.