-
pendulum expression variation – is this variation even possible?
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.