Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions pendulum expression variation – is this variation even possible?

  • pendulum expression variation – is this variation even possible?

    Posted by Scott G on March 14, 2006 at 12:02 pm

    hey script guys,

    i’m trying to come up with an automated way to wiggle a character legs in response to it’s position (a learning exercise to help me understand more about expressions).
    so far, i’m using the good old:
    distance=position[0];
    circumference=width*Math.PI;
    distance/circumference*360;

    to rotate an invisible wheel, then parenting legs to wheels (with the rotation of the leg set to -1 times the rotation of the invisible wheel (to keep the leg upright).
    the effect is like one of those old toys you push along the ground, the legs of a creature go round and round, up and down, silly cartoony walk motion. hurrah, it worked, etc.

    BUT what i would prefer is this:
    the legs to oscillate from the hip, between, say, 30 and -30 degrees, and when they hit a max/min value, they swing back the other way.

    i can’t for the life of me imagine what kind of math is needed, as although distance (my driving force) is always increasing (say, from left to right), i dont want the legs to go round and round like spinning fans.

    if i could get some pointers, then i could, presumably, combine the two, and use the back-forth oscillation, parented to the roundy-uppy-downy wheels, and get a satisfactory leg motion of a leg swinging forward to take a step, coming down to the ground, changing angle as the body moves forward, then lifting to take another step.

    is that clear?
    okay, as another example, imagine the hands of a clock driving a pendulum (ignore gravity). as long as the hands keep turning, the pendulum keeps swinging. if the hands stop, the pendulum stops, whatever position it’s in. if the hands turn back, the pendulum starts going the other way, it’s speed proportional to that of the clocks hands.

    it’s the min-max limits, and the one-way-then-reversing-loop that’s stumping me. how can i get it to hit the min/max and then reverse, while my distance steadily increases??
    please help!

    thanks,
    scott.

    Ryan Hill replied 20 years, 2 months ago 2 Members · 2 Replies
  • 2 Replies
  • Scott G

    March 14, 2006 at 12:09 pm

    i’m thinking it involves a sin or a cos with a limit, but the reverse-direction-loop is still stumping me.
    as i started learning expressions last week perhaps i’m in over my head already – i’m certainly not yet aware of all the key words and properties specific to after effects, and i admit this may be part of my problem. 🙂

  • Ryan Hill

    March 14, 2006 at 3:57 pm

    As I understand, a sin wave will describe the horizontal motion of a pendulum.

    You could anchor your legs at the hips and base their rotation on a sin of the location. Parent them to the body and then just move the body. You can access the leg’s absolute position, instead of the position relative to its parent, with something like:

    toWorld(position)

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