ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Delaying Keyframes via Slider & Layer Index

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Christopher Bly
Delaying Keyframes via Slider & Layer Index
on Nov 3, 2017 at 8:40:16 pm

So I'm currently trying to write an expression that causes keyframes to be delayed based on both a slider and their layer index so I can quickly retime a large animation sequence. To explain the code itself a bit more, I'm using a slider called "Time Progression" in place of the time function so I can control the speed of time as well as start/stop/reverse it and all that using keyframes, this is in the expression as the variable pTime. I've got another slider called "Animation Delay" that represents the number of frames that each progressive layer is delayed by, in my current comp it's set to something crazy like 819 for testing purposes. The layer is also having four subtracted from its index so the expression will ignore some extra layers at the top of the comp.

The problem I'm running in to is that the animation always starts as soon as the pTime slider starts, as if the delay is always 0. This is regardless of where I place the layer in the layer order. If anyone has any ideas on why this may be happening or how I may be able to fix it, please do. I am open to suggestions.

var pTime = framesToTime(thisComp.layer("CONTROL").effect("Time Progression")("Slider"));
var aDelay = thisComp.layer("CONTROL").effect("Animation Delay")("Slider");
var nIndex = index-4;
var startTime = aDelay*nIndex;
var key1 = thisProperty.key(1);
var key2 = thisProperty.key(2);
var keyDuration = key2.time-key1.time;

if (pTime&lt;=startTime){
}else if(pTime>startTime && pTime&lt;(startTime+keyDuration)){

Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2018 All Rights Reserved