Forums › Adobe After Effects Expressions › Wiggle expression triggered by multiple keyframes
Wiggle expression triggered by multiple keyframes
Kris Higgins
November 25, 2019 at 8:13 pmNew to expressions. Here’s what I’m trying to accomplish:
A layer has multiple keyframes changing the position. I’d like to have the wiggle expression activate with each change of position, and then have the wiggle quickly decay.
For example, from 0:00-1:00 layer position is 960,540 and wiggle is not active. At 1:05 position changes to 1200,540 and wiggle is activated and decays over 1 second. At 5:00 position changes to 300,540 and wiggle is activated and decays over 1 second.
I’m constantly adjusting the timing of the keyframes, so I’d prefer to not tie the wiggle to specific times but to the change of the keyframe values.
Any suggestions?
Thanks!
Oleg Pirogov
November 27, 2019 at 1:52 pmJust to throw in something to start with, this expression activates a fading-out wiggle for one second after each keyframe which has a non-zero speed at the moment just before it (which suppose to correspond to “change of position”):
n = 0;
if (numKeys > 0){
n = nearestKey(time).index;
if (key(n).time > time){
n--;
}
}
if (n == 0){
t = 0;
}else{
t = time - key(n).time;
}if (n > 0){
if (speedAtTime(key(n).time-thisComp.frameDuration/10)){
linear(time, key(n).time, key(n).time+1, wiggle(10, 100), value);
}
else{
value;
}
}else{
value;
}
Kris Higgins
November 28, 2019 at 12:51 amThis is fantastic. Thank you!
I’ve been trying to figure out how to link the expression to another layer with this.Comp(“other layer name”), but I can’t figure out where to place it within the expression to make it work. Somewhere within n = nearestKey(time).index;?
Log in to reply.