Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Loop animation via expression.

  • Loop animation via expression.

    Posted by Konstantin Kartashov on July 9, 2016 at 1:10 pm

    Hi everybody!
    I`m trying to link playback of one object`s animation cycle to movement of another one. I use Duik morpher to link all keyframes to one slider and link this slider to x-position of null object. The point is to make it work in cycle. I actually done it (may be in a little weird way). See the code below.

    Here 15 is a length of animation cycle. It works, but have one issue – when position goes lower zero the loop stops playing. I understand why it behave this way, but don`t know how to fix it.
    P.S. sorry for cyrillic letters in the code, unfortunately I have russian version of AE. Пусто 1 equals Null 1.

    if ((thisComp.layer("Пусто 1").transform.xPosition) <15) (thisComp.layer("Пусто 1").transform.xPosition) else (thisComp.layer("Пусто 1").transform.xPosition)-(Math.round((thisComp.layer("Пусто 1").transform.xPosition)/15-0.5))*15

    Konstantin Kartashov replied 9 years, 10 months ago 2 Members · 4 Replies
  • 4 Replies
  • Dan Ebberts

    July 9, 2016 at 3:29 pm

    Like this maybe:


    x = thisComp.layer("Пусто 1").transform.xPosition;
    if (x < 0)
    15 + x%15
    else
    x%15

    Dan

  • Konstantin Kartashov

    July 10, 2016 at 10:34 am

    Thank you very much, Dan,
    Everything`s works as needed. Could you please explain what “%” symbol means here?

  • Dan Ebberts

    July 10, 2016 at 1:54 pm

    That’s the JavaScript modulus operator, which returns just the remainder from a division operation. So the result of
    35 % 15 would be 5, for example.

    Dan

  • Konstantin Kartashov

    July 10, 2016 at 3:19 pm

    cool! thank you again!

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