Expression with delay

Copy link to clipboard
Copied
Hi,
I'm a nooby when it comes to expression, so can anyone please help me with how I can create a certain expression?
I think it's quite simple. I've got 2 layers. One layer has an animation (leader) and the other one needs to follow. Only with a delay of 1 frame. The animations happens on "position", "scale" and "rotation".
Thanks you very much in advance!
Best regards,
John
Copy link to clipboard
Copied
These should work:
thisComp.layer("leader").transform.position.valueAtTime(time-thisComp.frameDuration)
thisComp.layer("leader").transform.scale.valueAtTime(time-thisComp.frameDuration)
thisComp.layer("leader").transform.rotation.valueAtTime(time-thisComp.frameDuration)
Dan

Copy link to clipboard
Copied
Hi Dan!
this really helps! Thank you so much.
Only one more question, because how can I change the number of frames it delays on this expression?
Best regards,
John
Copy link to clipboard
Copied
This should work:
delayFrames = 3;
delay = framesToTime(delayFrames);
thisComp.layer("leader").transform.position.valueAtTime(time-delay)
Dan

Copy link to clipboard
Copied
Again this works perfect! Thank you!
Copy link to clipboard
Copied
These kinds of delays can also be done easily with mamoworld's iExpressions for After Effects.
This requires no code writing at all:
Copy link to clipboard
Copied
Dan, it's been 4 years since this originally was posted... but I'm just finding it!
I want to use the "leader" layer to control multiple objects. I have three boxes on screen and one Null (leader).
The Null's Y position is keyframed to move onto the screen from the bottom.
I want box #1 to come on with a delay (as explained above) which works fine.
I want box #2 to come on with a slightly longer delay (easy enough), but I want it to come down from the top of the screen: to mirror the Null's motion.
I know that there's probably 5 year olds out there that can do this for me... but, I'm at the office.
Copy link to clipboard
Copied
Hey Bryan, I don't know if you'd still care for a solution, as it has been a few years since you inquired.
I just stumbled upon this thread while looking for some answers for a different question of mine, but I recognized your name... Maybe you are a relative of one of my in-laws. I can't quite put my finger on it.
Anyways!
I'll start with my expression for the delay. I went with a "daisy-chain" expression in which the layer references other layers in respect to itself (index). The leader object contains the motion and no expression controls.
All layers below use this expression:
thisComp.layer(index-1).transform.position.valueAtTime(time-delay);
I used a slider to control my delay. Here's a screenshot of my timeline.
Here's the delay in action.
Now, to answer your question. You would like to keep the motion and delay, but have the object enter from the opposing side of the screen. This can be done by parenting that layer to a Null object. With the null, you can adjust any of the delayed layer's transform elements without effecting the delay expression.
In my example, I had to adjust my anchor point in order to center the layer where I wanted it.
Here is a screen shot of my timeline.
And finally here it is in action.
Like everything After Effects related, I'm sure there are a few different ways to skin this cat.
If you have questions, lemme know!
Hope this helps you out Bryan or really, anybody!
Copy link to clipboard
Copied
Interesting — there are a few Goughs out there, but it's not super common.
Also, it's a famous street name in San Francisco.
Thanks for taking time to work through this—it HAS been a while, so I can't even remember what this was for!?

