Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Animator root motion or character controller?

Discussion in 'Animation' started by Zexanima, Sep 20, 2014.

  1. Zexanima

    Zexanima

    Joined:
    Jan 2, 2014
    Posts:
    33
    I have been moving my character with CharacterController.Move() so far. However I've gotten to the point of adding a jump animation. Apply Root Motion would be great for this as it's a complex jump animation, however, with apply root motion it ignores physics.
    1. Is there a good way to to get the CharacterController to follow along with a complex jump animation? (Slow down, flip, then land taking a couple steps to slow down)
    2. Is there any way for physics to work with Apply Root Motion? (Going up steps, running in to walls, falling)
    An answer to either question would help me greatly.
     
  2. Mecanim-Dev

    Mecanim-Dev

    Joined:
    Nov 26, 2012
    Posts:
    1,675
    Yes you can, for clip that the height of the character change during the clip you need to change the importer option: root transform Position (Y).

    Basically what this options does is it control how the gravity affect this clip.
    When On the gravity will affect your avatar when playing this clip.
    When Off the gravity won't affect your avatar when playing this clip.

    In your case you want to put this option at Off because your jump already emulate the gravity.

    If you want more control over this you can create a GravityWeight parameter on your controller, this is a special parameter that control how physic affect your animation, And you can add an additionnal curve on your jump clip that drive this parameter, it start at 1 when the character is running, then goes to 0 when the character lift off the ground and goes back to 1 when it land. Take a look at this screen shot

    gravite.png

    Best regards,
     
    FurionK likes this.
  3. IsGreen

    IsGreen

    Joined:
    Jan 17, 2014
    Posts:
    206
    I think you can not use CharacterController component in mecanim(Animator component).

    Mecanim need rigidbody and collider to apply root motion.
     
  4. Mecanim-Dev

    Mecanim-Dev

    Joined:
    Nov 26, 2012
    Posts:
    1,675
    @IsGreen
    Of course you can, we have demo with an Animator component and CharacterController.
     
  5. IsGreen

    IsGreen

    Joined:
    Jan 17, 2014
    Posts:
    206
    I was wrong. You are right.
     
  6. BrutalDumbass

    BrutalDumbass

    Joined:
    Jul 10, 2017
    Posts:
    7
    Could you please link that demo?
    I did a script based movement but couldn't implement damping well and worry about animation.
    I want to use root motion on the ground but control in the air through .Move and simply blend the animation based on the velocity. But I can't get them to work. Using ApplyRootMotion teleports the player to the coordinates of the animation. I animated in Unity to quickly test out root motion and work on the gameplay right away
     
    MassimoFrancesco likes this.
  7. charles_xl

    charles_xl

    Joined:
    Oct 4, 2016
    Posts:
    87
    Apologies for necroing an old post, but is there no way to have characters moving with root motion respect collisions? Does collision detection have to be calculated manually this way?
     
  8. EmretheGanjaRaiders

    EmretheGanjaRaiders

    Joined:
    Dec 27, 2014
    Posts:
    21
    i use root motion with rigidbody and capsule collider. but when my player is child of an object with rigidbody attached its doesnt follow even when i set the players rigidbody to is kinematic. i think i need to add some values in OnAnimatorMove to get more control. In my first test project i used root motion with charactercontroller and had no need to add gravity it was like he has a rigidbody but i had no rigidbody attached.
     
  9. Dr-Hazrd

    Dr-Hazrd

    Joined:
    Jun 30, 2013
    Posts:
    3
    I am current running into a similar issue but I did find that
    Code (CSharp):
    1. Transform.position = animator.rootbone;
    works well when trying to keep the position of the character controller parent object and the child with root motion.

    I have created a different problem but this might help.