Forums › Adobe After Effects Expressions › alternating rotation between position keyframes
alternating rotation between position keyframes
Frank Feijen
February 4, 2010 at 9:12 pmHi there,
I have a layers position keyframed, but now i’d like to add some degree of alternating random rotation.
for example:
at poskeyframe1 – rotation:+12
at poskeyframe2 – rotation:-20
at poskeyframe3 – rotation:+22
at poskeyframe4 – rotation:-6
…
I must admit not to have clue on how to do this. But since there will be tons of positionkeyframes, an expression would surely save my wrists.Dan Ebberts
February 4, 2010 at 9:41 pmThis might be close:
maxVal = 25;
minVal = 5;
n = 0;if (position.numKeys > 0){
n = position.nearestKey(time).index;
if (position.key(n).time > time) n–;
}
if (n == 0){
seedRandom(1,true);
random(minVal,maxVal);
}else if (n == position.numKeys){
seedRandom(n,true);
a = random(minVal,maxVal);
if (n%2) a else -1;
}else{
seedRandom(n,true);
a1 = random(minVal,maxVal);
seedRandom(n+1,true);
a2 = random(minVal,maxVal);
if (n%2) a2 = -a2 else a1 = -a1;
t1 = position.key(n).time;
t2 = position.key(n+1).time;
linear(time,t1,t2,a1,a2);
}Dan
Frank Feijen
February 4, 2010 at 9:48 pmJust 1 word for you: AWESOME!!
works perfect, thanks.
Log in to reply.