Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Dynamically targeting layers with the index property

  • Dynamically targeting layers with the index property

    Posted by Sohrab Golestani on June 20, 2019 at 10:00 pm

    I have a .png that has been split up into a grid of segments using Utility Box v1.6 – each segment is one composition/layer. I want to scramble the image by rearranging the segments randomly. To do so, I rearranged the layers randomly, and I want to use an ease expression to move the layer from its existing position to the position of the layer under it:

    ease(time, 0, 2, value, thisComp.layer(index + 1).transform.position)

    This works great when I put it on layer 1 – it moves from its position to the position of layer 2 over 2 seconds. Great.

    When I copy that expression to layer 2, both layer 1 and layer 2 move to layer 3’s position.

    Is there a way to get after effects to evaluate the expressions independently?

    Thanks,

    ease(time, 0, 2, value, thisComp.layer(index + 1).transform.position)

    Sohrab Golestani replied 7 years, 1 month ago 2 Members · 2 Replies
  • 2 Replies
  • Oleg Pirogov

    June 21, 2019 at 6:42 am

    You’re telling layer 1 to move where layer 2 is ([…].transform.position). So, since layer 2 goes to layer 3, layer 1 also goes there.
    Instead, you’d wanna layer 1 to go to former position of layer 2, so […].transform.position.valueAtTime(0) may be the solution:

    ease(time, 0, 2, value, thisComp.layer(index + 1).transform.position.valueAtTime(0))

    P.S. […](0) – zero here is “the time when layer 2 was at the position you want layer 2 to go to”. If it’s some other time in your case, you should change it accordingly.

  • Sohrab Golestani

    June 21, 2019 at 2:11 pm

    That did the trick, thank you!

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