ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Wiggle expression triggered by multiple keyframes

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Kris Higgins
Wiggle expression triggered by multiple keyframes
on Nov 25, 2019 at 8:13:43 pm

New 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!


Return to posts index

Oleg Pirogov
Re: Wiggle expression triggered by multiple keyframes
on Nov 27, 2019 at 1:52:34 pm

Just 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;
}


Return to posts index

Kris Higgins
Re: Wiggle expression triggered by multiple keyframes
on Nov 28, 2019 at 12:51:55 am

This 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;?


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2019 CreativeCOW.net All Rights Reserved
[TOP]