Search Unity

Walk cycle loop stutters with root motion :(

Discussion in 'Animation' started by MaxYari, Feb 23, 2018.

  1. MaxYari

    MaxYari

    Joined:
    Feb 20, 2018
    Posts:
    13
    Hello everyone!
    I've encountered another problem during my newbie Unity experiments, i've imported walk cycle with root motion for my Generic rig character (all done in Blender and exported as FBX), problem is that this cycle doesn't loop seamlessly - there is a slight yet noticeable freeze of character at the end of each loop.

    Note: My loop consists of 4 steps instead of 2 so the difference between properly and not properly looped pair of steps is better visible.



    At the end you can see the same animation that I've fixed to a place in blender, in-place animation does look seamless, so i'm assuming it's not an issue of badly framed animation in blender. In fact blender animation is quite simple, it's just 5 copied/mirrored keyframes with 15 frames inbetween each pair.

    Also I thought that this stutter may appear due to animation's 60th frame = 0 frame, which afaik means that this frame repeats twice, but It's set up to play 0 - 59 in Unity which doesn't really fix an issue, as you can see.

    Would you mind shedding some light on this mystery?
     
  2. theANMATOR2b

    theANMATOR2b

    Joined:
    Jul 12, 2014
    Posts:
    7,790
    This is a animation issue rather than a specific blender issue so I think I can assist some.
    Although the animation keys are repeated in blender at 0 and 60 the issue might be the in/out curves coming out of frame 0 and going into frame 60.

    As an example
    upload_2018-2-23_12-22-48.png
    If this is the timeline 0-60 the curve coming out of frame 0 on the left (shown in red) might not match the curve going into key 60 on the right (shown in red).

    Since key 60 and key 0 are the same - when we put these together on the timeline we can see the interpolation into and out of keyframe 0 (which is also the 60th keyframe) will will show a slight hiccup/or hitch.

    upload_2018-2-23_12-25-37.png
    If we put the frame 55-60 on the left of the timeline - before frame 0 - we can see the curve (red) coming into frame 60 on the left - which is also frame 0 - does not match well with the exiting curve coming out of frame 0 - going into frame 5.


    Usually the fix for this is to have a linear/constant interpolation curve going into the last frame of the cycle and coming out of the first frame of the cycle. ;)

    Edit: Also good practice to duplicate the last frame and first frame of every animation cycle to keep curves from before/after cycles effecting the current animation cycle.
    So instead of having the next animation cycle begin at frame 61 - place a duplicated keyframe (of the entire rig) at frame 61 and start the next animation cycle at frame 62 - with a duplicated key of frame 62 at frame 63. So the next animation cycle would start at frame 63 rather than 62.
     
    ElXill and MaxYari like this.
  3. MaxYari

    MaxYari

    Joined:
    Feb 20, 2018
    Posts:
    13
    Wow, you've even illustradet it, thanks a lot!
    So, to be honest, I had this though, but then I looked at my curves http://prntscr.com/iitqic (Why I can't embed prntscr image here :( ) which seemed perfectly symmetric to me and thought "Nah, they all tile nicely, and the last frame is an exact copy of the first frame, this couldn't be the reason" and just discarded it. Now i took a look again and found that my forward movement of the root bone does this http://prntscr.com/iits5x in the last frame, and similar ease-in in the first frame. So putting them end to end will create an easing transition from one curve to another which I pretty sure corresponds to my issue :\

    A bit surprised that blender applies easing to all of the frames automatically, guess it's a standart practice and linear transitions just wouldn't look natural on non-mechanic objects.

    Am I getting this right that such a frame duplication only makes sense if you keep your different animations on a single timeline? (In blender i keep them as a separated actions). So those duplicated frames suppose to serve as a buffer to force any easing in to a linear horizontal transition?

    Offtop: Was modding some animations in to Gothic 2 a bit ago and was wondering why all native animations have duplicated frames between each combo attack in a combo set.. guess that's why. Interestingly enough not following this duplication rule and attempting to declare combo animations with moves lacking buffer frames - led to frames leak from one anim to another in a pretty ugly way, also those combo sets apparently required 20 useless frames to be present at the end of the animation, they werent visible in the game, but without them animation was cut much shorter without any apparent reason ¯\_(ツ)_/¯

    Well, thanks for the help! Will post if issue will still be present after I fix this easing.
     
    Last edited: Feb 23, 2018
  4. theANMATOR2b

    theANMATOR2b

    Joined:
    Jul 12, 2014
    Posts:
    7,790
    Yeah - I didn't mention ease in, ease out because I knew if you looked at the curves - if there were any easing in/out you would spot it and pick it up - and this is likely the issue - it looks like it in the video you provided.
    This is more related to blender so I can't help much. I use 3D Max pretty exclusively - but animation topics are nearly transferable between packages, so I try to help even if the subject is blender. ;)
    In Max (and probably all other animation packages) the artist can change the default interpolation curves. So I have them set to bezier curve - but always try to remember to convert the in/out curves to linear for this reason.
    I use animation layers mostly only for editing existing animations or for duplicating a motion and then editing it with extreme arcs. This way if the animation doesn't blend well with the exiting animation I can trash it and still keep the original in the same Max file. All keys get baked down onto one timeline anyway - so it doesn't hurt to animate that way. I sometimes do that when working pose to pose rather than linear keying.
     
  5. MaxYari

    MaxYari

    Joined:
    Feb 20, 2018
    Posts:
    13
    Just in case someone is interested - here's an update.

    I've tried setting those keyframe's curves to linear and this fixed an issue as was expected, BUT, since particular movement basically was defined by 3 keyframes, those easings was a noticeable part of motion and changing to linear on the ends made movement less natural. So after all I've found nothing better but to extend animation in Blender (4 steps instead of 2 for a walk cycle), then in the Unity I've just looped 2 steps in the middle. This way I both have seamless loop and proper easings.

    It doesn't seem like blender has kind of extrapolation that will stick animation transforms start-to-end seamlessly automatically, so I wasn't able to find another way to do this, if someone knows it - please do let me know.
     
  6. Skotrap7

    Skotrap7

    Joined:
    May 24, 2018
    Posts:
    125
    Just stumbled on this thread while trying to figure this out in my own animation. This helped immensely and the explanation(s) were very helpful!

    Thanks!