FORUMS: list search recent posts

Use Keyframe as trigger

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Lisa Schmölzer
Use Keyframe as trigger
on May 2, 2012 at 2:50:49 pm

Hi,

Does anybody know whether there is anyway to use a keyframe as a trigger for an animation in an expression?

What I'm talking about is, that you have a layer that's supposed to be doing a small repeating animation (i.e. pulsating / increasing and decreasing it's size) from time to time. The starting points of this animation are supposed to be triggered manually and than stop until the next trigger comes.

I was thinking about keyframing the animation once inside the object and then use a slider object that would be increased in value, every time I need the animation. The difficult thing is to link the two, because first of all the animation will have to start as soon as the value of the slider object increases and than stop until the value rises again.

I know that I could just copy and paste the keyframes but there has to be some way to solve this with an expression.
Does anybody have an idea how? Or do I need scripting to solve this problem (I do have some feeling for expressions but I have to admit that I'm quite a noob when it comes to scripting).

Thanks a lot in advanced,

Lisa


Return to posts index

Kevin Camp
Re: Use Keyframe as trigger
on May 2, 2012 at 5:31:30 pm

this may work for you..

when i've needed to 'recall' an animation at specific points i've used an expression like the one bellow. it looks at layer markers on the layer for timing of the animation for a given property.

so, say your scale animation is:
key1: 00:00f -- [50,50]
key2: 00:15f -- [100,100]
key3: 01:00f -- [50,50]

the expression will play that scale animation every time it passes a layer marker on that layer.

n = 0;
if (marker.numKeys > 0){
n = marker.nearestKey(time).index;
if (marker.key(n).time > time) n--;
}

if (n > 0){
valueAtTime(time-marker.key(n).time);
}else{
valueAtTime(0);
}


Kevin Camp
Senior Designer
KCPQ, KMYQ & KRCW


Return to posts index

Lisa Schmölzer
Re: Use Keyframe as trigger
on May 4, 2012 at 8:51:57 am

Wonderful! This works just perfect! Thank you so much!
Cheers, Lisa


Return to posts index


David Cabestany
Re: Use Keyframe as trigger
on Apr 20, 2016 at 9:56:36 pm

Kevin,

Any idea how to use this expression to trigger the animation every given time (for example once every minute) instead of using keyframes?

Best,
D.


Return to posts index

Dan Ebberts
Re: Use Keyframe as trigger
on Apr 20, 2016 at 10:38:45 pm

Something like this maybe:

segLength = 60;
t = (time - inPoint)%segLength;
valueAtTime(t)


Dan



Return to posts index

David Cabestany
Re: Use Keyframe as trigger
on Apr 20, 2016 at 10:56:52 pm

Mr. Dan Ebberts to the rescue as always! Thanks!!!

Just for my own understanding, would you mind explaining why the modulo operator?
I understand that segLength is how often I wan my animation to repeat, in this case every 60 seconds. Then t is the comp's time minus the in point, in this case the start of my comp, so that leaves us with the following:

at 60 seconds it would be

t=60-in point (which is 0) = 60

60/60 = 1, % (the remainder) = 0

so then

valueAtTime(t) would be 0, right?

How does that produce the desired behavior?

Thanks again!
D.


Return to posts index


Dan Ebberts
Re: Use Keyframe as trigger
on Apr 20, 2016 at 11:19:55 pm

Modulo 60 just creates a repeating loop from 0 to 59.99... as the time increases continuously.

Dan



Return to posts index

David Cabestany
Re: Use Keyframe as trigger
on Apr 24, 2016 at 4:30:58 pm

I see. Thanks!
D.


Return to posts index

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