Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Expression Driven Loopable Motion

  • Expression Driven Loopable Motion

    Posted by David Sikes on May 14, 2017 at 3:18 pm

    I frequently use Math.sin(time) to drive a looping animation—like adding a little Y rotation to a logo that will stay on a screen for a while, scaling up and down some text, etc.

    The problem I always run into is length of comp to make sure that it loops seamlessly. It’s usually not a huge deal to find a point that loops well, but sometimes I need the comp to be an exact time that doesn’t line up well with the sin wave.

    My brute force solution has been Math.sin(time*x) and just tweak x until it works—but I figure there’s a more elegant solution out there, ideally one that can use the length of comp to automatically adjust the sin wave to fit the comp.

    Does anyone have any ideas? I’m open to not using Math.sin, as well—I just like how it creates smooth interpolation and only requires easy math.

    Alternatively, what I really want to exist in the world is an After Effects equivalent for Greyscalegorilla’s Signal—that would do exactly what I’m asking for, so if anyone knows of a script or plugin that does that, please share!

    David Sikes replied 8 years, 11 months ago 2 Members · 2 Replies
  • 2 Replies
  • Dan Ebberts

    May 14, 2017 at 6:02 pm

    The trick to making Math.sin() loopable is to include Math.PI*2 in the equation so you get complete revolutions. Try this:

    amp = 25;
    n = 3; // number of complete oscillations;
    amp*Math.sin(time*n*Math.PI*2/thisComp.duration)

    Dan

  • David Sikes

    May 15, 2017 at 4:01 pm

    Thanks Dan! That’s exactly what I needed.

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy