Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Automating a simple ‘walk’ cycle

  • Automating a simple ‘walk’ cycle

    Posted by James Huenergardt on July 10, 2012 at 6:31 pm

    Hi,

    I’m working on a project where I’m doing some very simple animation using 2D characters.

    https://www.youtube.com/watch?v=a96Vzfi86cg

    What I’m wanting to do is figure out how to automate a very simple ‘in/out/scissors’ style walk cycle when I move the character left or right.

    I want the legs to rotate in and out like the video link above when I move the character’s position so the faster I move him, the faster his legs move, or the slower I move him, the more slowly they go.

    It’s kind of like moving a car along the x-axis and having the wheels rotate around as it moves, but the wheels do that automatically.

    Is this even possible?

    Thanks,

    Jim

    Reel Inspirations – http://www.reelinspirations.com
    Commercials, Dramas, Image Pieces, Documentaries, Motion Graphics

    Mauricio Domingues replied 13 years ago 3 Members · 5 Replies
  • 5 Replies
  • Dan Ebberts

    July 10, 2012 at 9:01 pm

    It’s hard to see the walk cycle in the linked video, but you should be able to set up a relationship between total horizontal distance moved and rotation angle. It’s hard to be more specific without knowing exactly what you’re trying to do.

    Dan

  • James Huenergardt

    July 10, 2012 at 9:52 pm

    Here is a better example of what I’m after:

    https://www.youtube.com/watch?v=3fKRxadmTjU&feature=youtu.be

    Reel Inspirations – http://www.reelinspirations.com
    Commercials, Dramas, Image Pieces, Documentaries, Motion Graphics

  • Dan Ebberts

    July 11, 2012 at 12:25 am

    This isn’t perfect, but I think it’s close. It assumes that the legs are parented to a layer named “body”, and body is keyframed to move horizontally. This would be the expression for rotation of the left (your left) leg:


    body = thisComp.layer("body");
    len = height; // length of leg
    a = 15; // max angle
    startX = body.transform.position.valueAtTime(inPoint)[0];
    stride = 2*len*Math.sin(degreesToRadians(a));
    d = (body.transform.position[0] - startX)%stride;
    if (d < stride/2)
    angle = radiansToDegrees(Math.asin(d/len))
    else
    angle = radiansToDegrees(Math.asin((stride -d)/len));
    angle

    For the right leg, just change the last line to :

    -angle

    Dan

  • James Huenergardt

    July 12, 2012 at 8:46 pm

    Dan, you are a genius. Wow, that math is crazy.

    I have no idea what is going on (for the most part) but was able to adjust stride, etc. to get things working nicely.

    I’m a former programmer (Actionscript, Javascript, database, etc.) but never did crazy math like that.

    Way cool. Thanks so much!

    Reel Inspirations – http://www.reelinspirations.com
    Commercials, Dramas, Image Pieces, Documentaries, Motion Graphics

  • Mauricio Domingues

    April 16, 2013 at 10:29 pm

    The expression works pretty well.
    But the “legs” won’t do the way back so the animation looks kinda jagged.
    Anyone knows how to modify this?
    Thanks in advance!

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy