How to Use valueAtTime in After Effects
In Adobe After Effects, the valueAtTime expression
allows you to sample and apply the value of any property at a specified
point in time rather than the current frame. This guide covers how
valueAtTime works, its syntax, and how to use it to offset
animation timing across single or multiple layers without shifting
keyframes manually.
What Is valueAtTime?
valueAtTime is a built-in expression method that
evaluates a property at a given time value, measured in seconds. Instead
of reading what a layer is doing at the current playhead position
(time), it allows the property to look forward or backward
across the timeline.
The core syntax is:
property.valueAtTime(t);property: The target property (e.g.,transform.position,transform.rotation, oreffect("Slider")("Slider")).t: The specific time in seconds from which to fetch the value.
Offsetting Animation on the Same Property
To create an echo or delayed movement on the same property that already contains keyframes, you can subtract time from the current playhead:
delay = 0.5; // Delay in seconds
valueAtTime(time - delay);timerepresents the current comp time in seconds.- Subtracting
delaycauses the property to read the keyframed values from 0.5 seconds in the past, effectively delaying the animation. - Adding a value (e.g.,
time + delay) causes the property to anticipate the animation ahead of time.
Linking Multiple Layers to a Leader Layer
The most common use of valueAtTime is creating trailing
or cascading motion across several follower layers tied to a single
animated "leader" layer.
1. Fixed Time Delay
Apply this expression to the Position property of a follower layer to
track a layer named "Leader" with a fixed delay:
leader = thisComp.layer("Leader").transform.position;
delay = 0.2; // 0.2 second offset
leader.valueAtTime(time - delay);2. Dynamic Delay Based on Layer Order (Index)
To duplicate layers and have each one automatically delay relative to
its position in the layer stack, use the index
property:
leader = thisComp.layer("Leader").transform.position;
delayPerLayer = 0.1; // 0.1 second delay between each layer
offset = (index - thisComp.layer("Leader").index) * delayPerLayer;
leader.valueAtTime(time - offset);As you duplicate the follower layer, its index
increases, automatically increasing the time offset for that layer
without modifying the code.
Offsetting by Frames Instead of Seconds
Because valueAtTime operates in seconds, calculating
precise frame counts can be awkward. Use the framesToTime()
utility function to define offsets using frame counts directly:
leader = thisComp.layer("Leader").transform.position;
framesDelay = 5; // Delay by 5 frames
leader.valueAtTime(time - framesToTime(framesDelay));Practical Tips for Using valueAtTime
- Applicability:
valueAtTimeworks on any property with keyframes or continuous changes, including spatial properties (Position, Anchor Point), one-dimensional properties (Opacity, Rotation), and color properties. - Expression Loops: If the target property is driven
by another heavy expression (such as
wiggle()), usingvalueAtTimeforces After Effects to evaluate that expression at both the current time and the offset time, which can increase render times. - Pre-Composition Timing: If sampling across nested
compositions, ensure time-remapping or layer start points are accounted
for, as
timerefers to the active composition's local timeline.