ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Does anyone understand why I'm getting this expression glitch?

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
louis Hamwey
Does anyone understand why I'm getting this expression glitch?
on Apr 30, 2020 at 4:54:13 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: https://drive.google.com/file/d/1IMhhh08nqabhNaIRikGt9OyQjsgM9-3Z/view?usp=...

On the "X Position":

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


Return to posts index

Dan Ebberts
Re: Does anyone understand why I'm getting this expression glitch?
on Apr 30, 2020 at 5:29:47 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")


Dan



Return to posts index

louis Hamwey
Re: Does anyone understand why I'm getting this expression glitch?
on Apr 30, 2020 at 6:05:19 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!


Return to posts index


Dan Ebberts
Re: Does anyone understand why I'm getting this expression glitch?
on Apr 30, 2020 at 6:18:57 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.

Dan



Return to posts index

louis Hamwey
Re: Does anyone understand why I'm getting this expression glitch?
on Apr 30, 2020 at 6:07:32 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.


Return to posts index

Andrei Popa
Re: Does anyone understand why I'm getting this expression glitch?
on Apr 30, 2020 at 5:30:06 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


Andrei
My Envato portfolio.


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2020 CreativeCOW.net All Rights Reserved
[TOP]