Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions pendulum swing at start of layer

  • pendulum swing at start of layer

    Posted by Jeff Nelson on March 30, 2012 at 7:27 pm

    Hi All,

    This should be easy but I can not get this work. I am using the below expression to get a layer (pre comp of a few layers) to swing with decay (you know Dan’s old pendulum with decay, or slight modification of it).

    The expression makes the layer swing with decay but only at the start of the master composition. I can not off set the layer to start later in the composition, say at 30 seconds in. From my understanding the “startT = thisLayer.startTime” should take care of that.

    Here is a screen shot to help explain what I am talking about.

    Not that is should matter but I am using CS5.5.

    What am I doing wrong? Any help would be greatly appreciated.

    Cheers,
    jeff

    veloc = 7; 
    amplitude = 90;
    decay = .7; 
    startT = thisLayer.startTime;

    amplitude*Math.cos(veloc*(time-startT))/Math.exp(decay*time)

    variable force, inc
    video production/motion graphics durham, nc

    Nathan Mallon replied 13 years ago 3 Members · 7 Replies
  • 7 Replies
  • Dan Ebberts

    March 30, 2012 at 8:26 pm

    Try it this way:

    veloc = 7;
    amplitude = 90
    decay = .7;
    t = time – inPoint;
    amplitude*Math.cos(veloc*t)/Math.exp(decay*t)

    Dan

  • Jeff Nelson

    March 30, 2012 at 8:41 pm

    Thanks Dan! I am away from that computer now but I will try it Monday, I will let you know if it works.

    Question to help me possibly understand:

    You have “t” being multiply by both the “veloc” and “decay”, but mine only had the “startT” being multiplied by “veloc” is that the problem?

    I am trying to understand because I did not come up with the expression, I borrowed it from https://www.macprovideo.com/hub/after-effects/create-swinging-banner-in-after-effects. He used exactly what I had and it seemed to work for him. I am just trying to better understand how to control when an expression starts.

    Thanks again for your time.

    variable force, inc
    video production/motion graphics durham, nc

  • Dan Ebberts

    March 30, 2012 at 8:54 pm

    Yes, the trick is to replace both references to “time” in the calculation with time-since-in-point. You can use the layer’s start time if it’s the same as the in point, but I use “inPoint” just in case they’re different.

    Dan

  • Nathan Mallon

    March 28, 2013 at 12:41 am

    Hey! This is almost exactly what I was looking for.

    Is there any way to make it so that when the swing dies off, later in the composition I could keyframe it to make it swing again….?

    Maybe using a slider? Any help would be appreciated.

  • Dan Ebberts

    March 28, 2013 at 1:25 am

    This would trigger the oscillation wherever there’s a layer marker:


    n = 0;
    m = marker;
    if (m.numKeys > 0){
    n = m.nearestKey(time).index;
    if (m.key(n).time > time) n--;
    }
    t = (n > 0) ? time - m.key(n).time : 0;

    veloc = 7;
    amplitude = 90
    decay = .7;
    amplitude*Math.sin(veloc*t)/Math.exp(decay*t)

    Dan

  • Nathan Mallon

    March 28, 2013 at 3:11 am

    Thanks so much Dan, this is perfect

  • Nathan Mallon

    May 2, 2013 at 9:08 am

    Thanks so much Dan!

    At the moment the way this works when I place the marker it triggers but makes the item jump back to the 0 axis point and start from there. Would there be a way to make it i guess trigger but happen dynamically from whatever point in a swing it’s at?

    Hope that makes sense…

    Thanks again!

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