Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Forums Adobe After Effects Expressions Does anyone understand why I’m getting this expression glitch?

  • Does anyone understand why I’m getting this expression glitch?

  • louis Hamwey

    April 30, 2020 at 4:54 pm

    I am trying to make a ruler with different length tick marks that I can also animate the distance between the ticks. I set it up so each tick is it’s own layer and the distance between them is controlled by a simple expression on the X Pos and a slider.

    It works perfectly, up until I add what seems to be too many ticks. When I add more It glitches in an odd way, where chunks of the ruler move unexpectedly, some disappear from view, and the more I add the more it jumps (almost like a random seed). Originally I thought it was a display error, but the values X Pos values change as well, so something is happening in the calculation.

    I restarted, dumped my cache and other the other things I could think of that usually help with glitches. I am running on AE 17.0.6 on a new machine I built so I’m doubting it’s my software or hardware.

    Does anyone have any idea what could be the problem or a better solution for what I am trying to achieve? Here is a link to the project if you want to see my setup:

    On the "X Position":

    thisComp.layer(index-1).transform.xPosition + thisComp.layer("Control").effect("Distance")("Slider")

  • Dan Ebberts

    April 30, 2020 at 5:29 pm

    I think you’ll get better performance if you avoid a cascading expression (where each expression depends on the result from the expression in the previous layer) and just use a straight ahead calculation based on layer index, like this (not tested):
    thisComp.layer(2).transform.xPosition + (index-2)*thisComp.layer(“Control”).effect(“Distance”)(“Slider”)


  • Andrei Popa

    April 30, 2020 at 5:30 pm

    Try to directly calculate the distance for each tick. Accessing it with index-1 is reaaaly slow because I think AE re-calculates each position to the current one. So, let’s say layer 30, has to calculate 29 other positions so it can add the distance in the end. Try directly multiplying the distance with the number of the current tick. firstiIndex must be the index of your first tick:

    firstIndex = 2;
    d = thisComp.layer("Control").effect("Distance")("Slider");
    value + (index-firstIndex)*d

    My Envato portfolio.

  • louis Hamwey

    April 30, 2020 at 6:05 pm

    This worked perfectly thank you so much for your help! Do you mind explaining why this would work better? Is it simply because it’s only having to calculate once as opposed to every single layer? Makes it easier on the processor and thus less likely to have a glitch like mine? I’m trying to learn more about expressions and best practices for them. Thanks again!

  • louis Hamwey

    April 30, 2020 at 6:07 pm

    and for context I also posted this on reddit and someone recommended that I switch to the legacy expression engine which also worked with my original expression.

  • Dan Ebberts

    April 30, 2020 at 6:18 pm

    That’s pretty much it. They way you had it, the expression in layer n requires the expression engine to recalculate the expression in layer n-1, which requires recalculation of layer n-2, and so on, increasing geometrically with the number of layers. It can bog things down in a hurry.


Viewing 1 - 6 of 6 posts

Log in to reply.

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