Creating Procedural Animation Offsets with valueAtTime() in After Effects
Learn how to use the valueAtTime() method in After Effects to create procedural animation offsets, eliminating the need to manually shift keyframes across multiple layers.
05 Dec 2025, 00:39 UTC

Solving the Manual Keyframe Offset Problem
When animating a group of objects—such as a flock of birds or a cascading menu—manually shifting keyframes for every layer is inefficient and difficult to iterate. If the timing of the lead animation changes, every subsequent layer must be manually adjusted.
The valueAtTime() method solves this by allowing a layer to "look back" or "look forward" in the timeline to sample a value from another property. This creates a procedural delay where follower layers automatically mirror the leader's motion with a precise time offset.
How valueAtTime() Works
The valueAtTime(t) method is a function applied to a property. Instead of returning the value at the current playhead position, it returns the value of that property at the specific time t (measured in seconds). By using the global time variable and subtracting a value, you create a temporal offset.
Implementation Example: The Follower System
To set up a system where multiple layers follow a single "Leader" layer with a 0.5-second delay, follow these steps:
- Create a layer named Leader and animate its Position property with keyframes.
- Create a second layer (the Follower).
- Alt-Click (Windows) or Option-Click (macOS) the stopwatch of the Follower's Position property to open the expression editor.
- Enter the following code:
// Define the delay in seconds
var delay = 0.5;
// Reference the Leader layer's position at the current time minus the delay
thisComp.layer("Leader").transform.position.valueAtTime(time - delay);
Dynamic Offsets for Multiple Layers
If you have ten follower layers, manually changing the delay variable for each is still tedious. You can automate the delay based on the layer's index (its position in the layer stack) to create a cascading effect:
var delayPerLayer = 0.1;
var myDelay = (index - 1) * delayPerLayer;
thisComp.layer("Leader").transform.position.valueAtTime(time - myDelay);
In this configuration, Layer 1 has 0s delay, Layer 2 has 0.1s, Layer 3 has 0.2s, and so on.
Performance and Technical Limitations
While powerful, valueAtTime() can impact composition performance because the expression engine must sample the referenced property for every frame of the render.
Computational Overhead
Performance degrades linearly as you add more layers. In complex compositions with hundreds of layers sampling a single leader, you may notice a significant drop in the frame rate of the RAM preview. To mitigate this, consider pre-composing the animated group or converting the expressions to keyframes once the timing is finalized.
Critical Failure Points
- Circular References: If Layer A uses
valueAtTime()to sample Layer B, and Layer B samples Layer A, After Effects will trigger a circular reference error. The expression engine cannot resolve which value comes first, and the properties will freeze. - Naming Dependencies: The expression
thisComp.layer("Leader")relies on the exact string name of the layer. If the Leader layer is renamed, the expression will break, and the property will return an error. - Missing Data: Sampling a value at a time before the first keyframe or after the last keyframe will return the value of the nearest existing keyframe (holding the value constant).
Verification and Diagnostics
To verify the expression is working correctly, use the following checks:
- Visual Offset: Move the playhead. The follower should mirror the leader's path exactly, but trailing behind.
- Negative Offset Test: Change
time - delaytotime + delay. The follower should now move before the leader does. - Error Checking: Check the Info Panel (Ctrl+I / Cmd+I). If the layer name is misspelled or the layer is deleted, After Effects will display an expression error here.
Rollback Procedure
Because expressions change the state of a property by disabling manual keyframe control, you can revert the property to its original state by clicking the expression stopwatch again to toggle the expression off. If you need to keep the resulting motion but remove the expression for performance, right-click the property and select Keyframe Assistant > Convert Expression to Keyframes.
0 replies
A thoughtful contribution can make all the difference. Be the first to share one.