FORUMS: list search recent posts

Triggering specific keyframes animations with marker comment

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Daniel Futerman
Triggering specific keyframes animations with marker comment
on Nov 12, 2015 at 7:26:48 am

Hi all,

I'm trying to trigger multiple keyframes animations once reaching an "OutPoint" marker.

So essentially, the layer marker should trigger the animation between keyframes 2 & 3. I'm doing this to give the user a simple way to adjust the out animation instead of manually re-adjusting keyfrmaes.

What I'd like to happen is if the user stretches the marker further in time, the animation between keyframes 1 & 2 would be slower, and once the time hits the marker "OutPoint" keframes 2 & 3 will come into action (the parameters between 2 & 3 never change).

It would be great if the same expression could be copy-pasted to the mask, position, scale, z rotation and opacity properties:



I've tried multiple expressions by Dan Ebbert but couldn't get it to work as I need.

Really appreciate your help!

After Effects Template & Photoshop Tutorials:
http://www.amigo-productions.com


Return to posts index

Miguel de Mendoza
Re: Triggering specific keyframes animations with marker comment
on Nov 12, 2015 at 11:04:21 am
Last Edited By Miguel de Mendoza on Nov 12, 2015 at 11:05:08 am

Look at this post: https://forums.creativecow.net/thread/227/30494

You can tweek it to change any property of any layer. Here is an example on how I use this tecchnique:

As you can see on top, there are various 'master' comps named "triangles_n". You only need to set the triangles(or any layer) position where do you want on each 'master' comp and then control the animations by the marker comment.


Return to posts index

Daniel Futerman
Re: Triggering specific keyframes animations with marker comment
on Nov 12, 2015 at 11:46:25 am

Thanks for your reply Miguel, looks very interesting but to be honest, modifying that code would be beyond my level of knowledge in expressions.

What changes would you make to apply it to my scenario? Or is there a simpler expression I could use instead?

Thanks a lot!

After Effects Template & Photoshop Tutorials:
http://www.amigo-productions.com


Return to posts index


Daniel Futerman
Re: Triggering specific keyframes animations with marker comment
on Nov 13, 2015 at 6:34:32 am

Anyone else? :-)

The only thing I have so far is the following, but it only the entire keyframe animation to start once reaching the marker, rather than having keyframe 2 start when reaching the marker.

(I found this expression on reddit)

// Keyframe your animation, starting on frame 0
// This property will animate at every marker on this layer

// If the property has no keyframes, the value at frame 0 is output
if (thisProperty.numKeys == 0) { t = 0; }

// Find the previous marker from current time
else {
n = 0;
if (marker.numKeys > 0){
n = marker.nearestKey(time).index;
if (marker.key(n).time > time){ n--;}
}

// If there is no previous marker, the value at frame 0 is output
if (n == 0){ t = 0; }

// Calculate t from elapsed time since the last keyframe
else{
m = marker.key(n);
t = time - m.time;
}
}
valueAtTime(t)


After Effects Template & Photoshop Tutorials:
http://www.amigo-productions.com


Return to posts index


Dan Ebberts
Re: Triggering specific keyframes animations with marker comment
on Nov 13, 2015 at 7:48:07 am

I think it would be like this:


tm = marker.key(1).time;
t1 = key(1).time;
t2 = key(2).time;
if (time < tm)
t = linear(time,t1,tm,t1,t2)
else
t = t2 + (time - tm);
valueAtTime(t)



Dan



Return to posts index

Daniel Futerman
Re: Triggering specific keyframes animations with marker comment
on Nov 13, 2015 at 8:18:21 am

You're simply amazing Dan. Thank you so much!!!

After Effects Template & Photoshop Tutorials:
http://www.amigo-productions.com


Return to posts index


Daniel Futerman
Re: Triggering specific keyframes animations with marker comment
on Nov 20, 2015 at 8:51:37 am
Last Edited By Daniel Futerman on Nov 20, 2015 at 8:52:31 am

Hi Dan,

I'm trying to figure out a way to slightly adjust the result of the expression.

What currently happens is that when dragging the marker to an earlier time, the animation speeds up between keyframe 1 & 2, and the speed between keyframes 2 & 3 stays the same. This is what I thought I wanted to happen.

But.. this results in a smooth animation between keyframes 1 & 2, and then slows down between 2 & 3, causing a not-smooth movement.

So bottom line is, I'd like the marker stimulate the "squeezing" (for lack of better word) of the keyframes as done while holding Alt and adjusting all keyframes.

I've attached a .gif to demonstrate what I mean, hope it helps!! :-)



After Effects Template & Photoshop Tutorials:
http://www.amigo-productions.com


Return to posts index

Dan Ebberts
Re: Triggering specific keyframes animations with marker comment
on Nov 20, 2015 at 7:11:39 pm

Try it this way:

tm = marker.key(1).time;
t1 = key(1).time;
t2 = key(numKeys).time;
t = linear(time,t1,tm,t1,t2);
valueAtTime(t)


Dan



Return to posts index

Daniel Futerman
Re: Triggering specific keyframes animations with marker comment
on Nov 20, 2015 at 10:51:36 pm

Dan you are a genius. Seriously - Thank you so much for your help, I truly appreciate it.

The code works perfectly, there's only one last thing I want to ask if possible to do -

Is there a way to have the exact same expression, but instead of having the marker location 'connected' to the final keyframe marking the end of the animation, it would be connected to the second keyframe indicating the beginning of the out animation. Hope this still makes sense!



So essentially, I guess it would be some sort of mixture between the two expressions? Because ideally, I would like the user to be able to quickly drag the marker on layer 1 to a new point in time (i.e. slower or faster animation speed), and then be able to drag layer 2 to the position of the marker - which marks the beginning of the out animation.

See what I mean? I hope it's possible to do :) This picture might help to explain what I mean.



After Effects Template & Photoshop Tutorials:
http://www.amigo-productions.com


Return to posts index


Dan Ebberts
Re: Triggering specific keyframes animations with marker comment
on Nov 20, 2015 at 11:03:32 pm

I'm confused. Isn't that what the first expression does?

Dan



Return to posts index

Daniel Futerman
Re: Triggering specific keyframes animations with marker comment
on Nov 20, 2015 at 11:30:04 pm

Sorry I thought that might have been confusing :) I'll try to better explain what I mean.

Yes that is what the first expression does, but then I have the problem of the fast speed between 1st & 2nd keyframes, and then slow again between the 2nd & 3rd keyframes.

The second expression you wrote does exactly what I need in terms of the result. What I was hoping to change in it is that the marker itself will connect to keyframe #2 instead of #3.

So essentially it's having the marker connected the same way as in the first expression, but have the result the same as the second expression.

Marker = Connected to second keyframe (i.e same as in the first expression, indicating the begining of the out animation).

Result = The same as the second expression.

New expression = a mixture between the two.

What happens in action: The user moves the marker on layer #1, which results in the effect of expression #2. The user then drags layer #2 to the time point of layer #1's marker, which results in a smooth transition between the two layers.

Does that make things more clear? Or have I completely confused you now? Probably the second option ;-)

After Effects Template & Photoshop Tutorials:
http://www.amigo-productions.com


Return to posts index


Dan Ebberts
Re: Triggering specific keyframes animations with marker comment
on Nov 21, 2015 at 12:12:55 am

Ah, maybe like this then:

tm = marker.key(1).time;
t1 = key(1).time;
t2 = key(2).time;
t = time*(t2-t1)/(tm-t1);
valueAtTime(t)

Dan



Return to posts index


Daniel Futerman
Re: Triggering specific keyframes animations with marker comment
on Nov 21, 2015 at 12:20:59 am

Thank you so much for your amazing help Dan! I have to head out of the office for a few hours but can't wait to get back and try this out!

After Effects Template & Photoshop Tutorials:
http://www.amigo-productions.com


Return to posts index

Daniel Futerman
Re: Triggering specific keyframes animations with marker comment
on Nov 21, 2015 at 9:48:04 am

Brilliant!!! Exactly what I needed!!

Thank you so very much Dan, your help has been amazing.

After Effects Template & Photoshop Tutorials:
http://www.amigo-productions.com


Return to posts index

Daniel Futerman
Re: Triggering specific keyframes animations with marker comment
on Nov 22, 2015 at 1:40:07 pm

Ok this is embarrassing, but I need help to refine the latest expression.

The expression works only if the layer itself starts at 00:00 seconds. Anything else, the keyframe animation begins earlier in time that the layer itself, as in the following example:



I tried modifying the expression for the past few hours but simply couldn't get my head around it :(

After Effects Template & Photoshop Tutorials:
http://www.amigo-productions.com


Return to posts index



Dan Ebberts
Re: Triggering specific keyframes animations with marker comment
on Nov 22, 2015 at 3:52:40 pm

Try it this way:

tm = marker.key(1).time;
t1 = key(1).time;
t2 = key(2).time;
t = t1 + (time-t1)*(t2-t1)/(tm-t1);
valueAtTime(t)


Dan



Return to posts index

Daniel Futerman
Re: Triggering specific keyframes animations with marker comment
on Nov 22, 2015 at 5:42:49 pm

YES!!! :D Perfect Dan! (And this time I'm 100% sure about it) ;-)

Thank you very very much for your help once again.

After Effects Template & Photoshop Tutorials:
http://www.amigo-productions.com


Return to posts index

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