FORUMS: list search recent posts

Marker triggered animation, more than one set of keyframes

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
David Cabestany
Marker triggered animation, more than one set of keyframes
on Apr 24, 2016 at 4:07:19 pm

I'm using the expression below to trigger animation each time a marker is passed. Right now it works for one single type of animation, for example movement in x.
Is there a way to revise the expression so it triggers different events based on markers? That way it would do a first set of x movement keyframes on the first marker, but then a completely different animation, for example movement in y on the second marker and so on. Each animation would have its own set of keyframes, independent from each other.

Maybe the second animation could follow markers in the layer, not the timeline? No idea.

As always, thanks everyone for your help.

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


Return to posts index

Dan Ebberts
Re: Marker triggered animation, more than one set of keyframes
on Apr 24, 2016 at 4:32:44 pm

Depending on you how you set things up, you should be able to use the marker's comment for that. If the comment is "x", do this, if it's "y" do something else.

Dan



Return to posts index

David Cabestany
Re: Marker triggered animation, more than one set of keyframes
on Apr 24, 2016 at 4:37:52 pm

how do i access the comment on the expression?


Return to posts index


Dan Ebberts
Re: Marker triggered animation, more than one set of keyframes
on Apr 24, 2016 at 5:25:35 pm

Like this:

marker.key(n).comment


Dan



Return to posts index

David Cabestany
Re: Marker triggered animation, more than one set of keyframes
on Apr 25, 2016 at 10:10:46 pm

Hey Dan,

I've been playing for a while now trying to integrate the comment into my expression, but each time it returns an error.
Would you mind helping me figure this out?

Best,
D.


Return to posts index

Dan Ebberts
Re: Marker triggered animation, more than one set of keyframes
on Apr 25, 2016 at 10:39:51 pm

Tough to do without more info about how you have things set up and exactly what you're trying to do.

Dan



Return to posts index


David Cabestany
Re: Marker triggered animation, more than one set of keyframes
on Apr 25, 2016 at 10:52:18 pm

I want to add the offset effect to a long video and have different movements happen:

From left to right
From right to left
From top to bottom
From bottom to top

I need to add all four motions as sets of keyframes and then have them occur at selected times using the markers on the layer, which I will label L,R,U,D or something like that.

The way the expression is working right now only one motion is allowed.

It's a super long video, so using markers instead of keyframes to trigger this animations is a huge time saver.

Best,
D.


Return to posts index

Dan Ebberts
Re: Marker triggered animation, more than one set of keyframes
on Apr 25, 2016 at 11:15:02 pm

Does the expression need to know what's happened in the past? I mean, if you run keyframes to move it from top to bottom, won't you need to have different versions for whether it's currently on the left or right?

Dan



Return to posts index

David Cabestany
Re: Marker triggered animation, more than one set of keyframes
on Apr 25, 2016 at 11:27:11 pm

No, it's a long video and the idea of doing this is to give the illusion that the footage is sliding into different footage when it will actually be sliding on itself. I'm planning on placing the markers where the cuts happen to minimize the cheat.


Return to posts index


Dan Ebberts
Re: Marker triggered animation, more than one set of keyframes
on Apr 25, 2016 at 11:51:11 pm

I assume it will look something like this (not tested at all) where based on the comment of the most recent marker, you set the start and stop keyframes of the animation you want to run:


n = 0;
if (marker.numKeys > 0){
n = marker.nearestKey(time).index;
if (marker.key(n).time > time) n--;
}
if (n > 0){
t = time - marker.key(n).time;
c = marker.key(n).comment;
switch (c){
case "L":
startKF = 1;
endKf = 2;
break;
case "R":
startKF = 3;
endKf = 4;
break;
case "U":
startKF = 5;
endKf = 6;
break;
case "D":
startKF = 7;
endKf = 8;
break;
default:
break;
}
valueAtTime(Math.min(key(startKF).time + t, endKF.time))
}else{
valueAtTime(0);
}


Dan




Return to posts index

Dan Ebberts
Re: Marker triggered animation, more than one set of keyframes
on Apr 25, 2016 at 11:52:48 pm

I can see one error already. This:

valueAtTime(Math.min(key(startKF).time + t, endKF.time))

should be this:

valueAtTime(Math.min(key(startKF).time + t, key(endKF).time))


Dan



Return to posts index

David Cabestany
Re: Marker triggered animation, more than one set of keyframes
on Apr 26, 2016 at 12:01:30 am

Oh my god!!!!!!!!! It works!!!!!!!!!!!IT WORKS!!!!!!!!!!!!!!!!!!!!
You just saved me days of manual editing with this nifty trick, Thanks so much!!!!!

There's an error though, albeit a small one, where it says endKF at the very end it needs to be endKf (lower case f)

I'm forever indebted to you.

Best,
D.


Return to posts index

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