Search Unity

  1. Calling all beginners! Join the FPS Beginners Mods Challenge until December 13.
    Dismiss Notice
  2. It's Cyber Week at the Asset Store!
    Dismiss Notice

Applying root motion to parent

Discussion in 'Animation' started by joshcamas, Nov 29, 2019.

  1. joshcamas

    joshcamas

    Joined:
    Jun 16, 2017
    Posts:
    875
    Hello!

    I'm having some huge issues with applying root motion to a parent. A solution I found was to do something along these lines:
    Code (CSharp):
    1.  
    2.         void OnAnimatorMove()
    3.         {
    4.             myparent.transform.position += animator.deltaPosition;
    5.         }
    6.  
    However, this deltaPosition is affected by the "snap" that happens after a animation has played. In other words, after the animation that involves root motion has completed, the character snaps back in place. Definitely not what I want.

    Is there any way to avoid this?

    Thanks
    Josh
     
  2. Kybernetik

    Kybernetik

    Joined:
    Jan 3, 2013
    Posts:
    622
    That sounds like the correct solution to me. I'm planning on adding exactly that to one of the Animancer examples and I can't see any reason it wouldn't work.

    Does the snap occur if you just apply it to the child normally? What about with regular root motion without that method at all?

    Does the delta position actually give a huge value on the last frame?
     
  3. joshcamas

    joshcamas

    Joined:
    Jun 16, 2017
    Posts:
    875
    For whatever reason, after returning to this now it works. The only thing I that I can think of is that I downgraded from 2019.14 to 2019.13. Not sure what happened there.