Search Unity

Walk forward and rotate

Discussion in 'Timeline' started by Wattosan, May 20, 2019.

  1. Wattosan

    Wattosan

    Joined:
    Mar 22, 2013
    Posts:
    460
    Hey!

    I would like my characters to walk forward, using a walk forward animation with root IK and at the same time slightly change their direction. So it should look like they are following a curved path/road.

    The way I currently set this up:
    1) I created an animation track for playing the animation
    2) I created another animation track for changing the gameobject's rotation on the Y axis.

    However, when they are played at the same time, the character rotates and the animation plays, but root motion is no longer applied, thus the character stays in one spot.

    A video of this can be seen below:


    Any help is much appreciated.

    Thank you!
     
  2. Wattosan

    Wattosan

    Joined:
    Mar 22, 2013
    Posts:
    460
    I just noticed that when I swapped the order of walk forward animation track and the rotation track (I moved the walk forward track below the rotation track), the walk forward track worked and the character moved forward. But this time there was no rotation.
     
  3. seant_unity

    seant_unity

    Unity Technologies

    Joined:
    Aug 25, 2015
    Posts:
    1,516
    For the root motion override, try using an override track on the animation track with clips instead of a separate track.
     
  4. vamky

    vamky

    Joined:
    Aug 9, 2014
    Posts:
    70
    Sorry but the override track result is the same. Only the button track will be effective. My animation track and the override track are both using clips, one for root motion and another for rotation.
     
  5. seant_unity

    seant_unity

    Unity Technologies

    Joined:
    Aug 25, 2015
    Posts:
    1,516
    You should be able to use an override track, that appears last, that overrides the root motion (it can be a button track). You can also use Avatar masks on override tracks to only animate certain portions of the hierarchy.
     
  6. vamky

    vamky

    Joined:
    Aug 9, 2014
    Posts:
    70
    The problem here is that the override track completely overrides the position (it should only add rotation) of the rootmotion so the character is no longer moving forward.

    Edit: I have uploaded a simple project of a sample scene of what I am doing, please take a look.
     

    Attached Files:

    Last edited: Jun 14, 2019
  7. seant_unity

    seant_unity

    Unity Technologies

    Joined:
    Aug 25, 2015
    Posts:
    1,516
    Ah, my mistake. Overriding only rotation won't work. Offsets and root motion apply translation and rotation together, so if you override one, you need to override both.
     
  8. seant_unity

    seant_unity

    Unity Technologies

    Joined:
    Aug 25, 2015
    Posts:
    1,516
    Alternatively you can animate the parent to set the rotation there.
     
  9. vamky

    vamky

    Joined:
    Aug 9, 2014
    Posts:
    70
    That's......kind of counter-intuitive way of doing it, right? I think what is missing here is really a kind of track that allow us to use root motion animation(or sample the movement curve inside the animation, then apply it to movement speed in timeline) to move along a curve/spline/path.
     
  10. seant_unity

    seant_unity

    Unity Technologies

    Joined:
    Aug 25, 2015
    Posts:
    1,516
    Yes, absolutely. It is counter intuitive. It's the only way to separate the translation and rotation of the root transform right now.

    Splitting off the root motion in a better fashion, and adding visualization and modification is absolutely a better way to go, and something that we have recognized and hope to address in the future.
     
    SamRock and vamky like this.
  11. Upp000

    Upp000

    Joined:
    Mar 4, 2021
    Posts:
    96
    Animating the parent doesn't work because the rotation pivot doesn't change.
    It is 2023 now, do you have a solution now?