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

Applying root motion to parent

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

  1. joshcamas

    joshcamas

    Joined:
    Jun 16, 2017
    Posts:
    1,276
    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:
    2,555
    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?
     
    protopop likes this.
  3. joshcamas

    joshcamas

    Joined:
    Jun 16, 2017
    Posts:
    1,276
    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.