Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Using expression to move a layer along predefined motion path by percentage + repeat!

  • Using expression to move a layer along predefined motion path by percentage + repeat!

    Posted by James Armstrong on October 10, 2011 at 9:47 am

    Hi, this is a tricky one.

    I have three layers in 3D space. I have a null with an angle control on it. What I want to do is have the layers move around a predefined circular path in 3D space with the angle control being in charge of the layers’ positions. Also the movement along the motion path must repeat every 360 degrees. ie. at 0 degrees rotation the layers are at position 1, at 180 degrees they are at position 2 and at 360 degrees they are at position 3 (which is the same as position 1). Another rotation of the angle control should send them round again.

    Basically I need to convert 0-360 degrees into a completion percentage of a motion path that has already been keyframed… and then repeat as necessary.

    The reason that the layers must be controlled by the angle control on the null is that it is also controlling their scale with a cos expression which allows the layers to scale up and back down with every full rotation of the control, thus allowing for looping animation. However the same won’t work for position because I want the movement to loop, not bounce…

    I can then just add keyframes to the angle control and control scale/position of all layers with one control.

    Any ideas? Thanks.

    James Armstrong replied 14 years, 11 months ago 2 Members · 2 Replies
  • 2 Replies
  • Dan Ebberts

    October 10, 2011 at 1:59 pm

    Try this:

    angle = thisComp.layer(“Controls”).effect(“Angle Control”)(“Angle”);
    pct = angle%360/360;
    t0 = key(1).time;
    t1 = key(numKeys).time;
    t = linear(pct,0,1,t0,t1);
    valueAtTime(t)

    Dan

  • James Armstrong

    October 11, 2011 at 9:57 am

    That’s awesome. Thanks so much. I went further and removed my scale expression and replaced it with this, allowing me more control over the layout.

    I applied an offset to the second and third layers – so now I have three layers that move around each other and scale all by adjusting and keyframing one control.

    Brilliant!

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