top of page

Marker-Based Animation Trigger

Background Line UI

Advanced Expression, Animation Techniques, Time Based Animation, Transform

Marker-Based Animation Trigger

This expression triggers animations based on the most recent composition marker by offsetting keyframe timing relative to the marker. If no marker is active, it holds the initial animation value.

Imagine you have a bouncing ball animation in After Effects and want it to restart every time a composition marker is placed. Apply this expression to the ball’s position property. Place markers at different times in the timeline, and the ball's bounce will begin from the start of its animation at each marker. If no marker is present, the animation will hold its initial position value.

m = thisComp.marker;

if (m.numKeys > 0) {
triggerTime = 0;

for (i = 1; i <= m.numKeys; i++) {
if (time >= m.key(i).time) {
triggerTime = m.key(i).time; // Use the most recent marker
}
}

if (triggerTime > 0) {
timeOffset = time - triggerTime; // Calculate the offset based on the most recent marker
valueAtTime(timeOffset); // Adjust the property value
} else {
valueAtTime(0); // Hold the initial state if no markers have been reached
}
} else {
0; // No animation if no markers exist
}

How to Use This Expression?

  1. Add Markers: In your composition, press * on your keyboard (numeric keypad) to add markers on the timeline where you want the animation to trigger.

  2. Animate a Property: Create keyframes for the property you want to animate (e.g., position, scale, or opacity).

  3. Apply the Expression: Select the property where you've created keyframes.
    Hold Alt (Windows) or Option (Mac) and click the stopwatch icon next to the property.
    Paste the expression into the text field that appears.

  4. Adjust Animation Timing: Move the markers along the timeline. The animation will restart at the marker times.

This works for any property that supports keyframes and markers.

Support Our Mission to Keep It Free

Your contribution ensures ongoing access to high-quality, easy-to-use After Effects expressions and libraries for

everyone.

Trending
Free After Effects Tutorials & Templates

As one of YouTube's leading creators of Motion Graphic Tutorials, we provide a diverse array of resources, including After Effects templates, royalty-free sound effects, and Photoshop PSD Templates. We also offer premium After Effects Templates and Sound Effects, designed to meet the needs of both beginners and professionals in the Motion Graphics field.

Copyright © 2025 Avnish Parker.

All Rights Reserved.

Follow Us

  • Youtube
  • Grey Facebook Icon
  • Twitter
  • Instagram
  • Patreon_logo_Small_edited_edited
Online Payment Icons
bottom of page