-
change direction with expression
Hi everyone,
Longtime user of Creative Cow, but this is my first ever post.
I’ve recently been learning After Effects expressions. I have a subcomp moving across the screen from left to right and I’m trying to get it to reverse direction when it reaches the halfway point of the screen. I have the following expression on its position property and I can’t understand how it doesn’t work:
direction = 1;
speedMultiplier = 500;
if (transform.position[0] > thisComp.width / 2)
{
direction = -1;
}
[time * speedMultiplier * direction, thisComp.height / 2];
Using the same if statement I can change its color using a fill mask, so why can’t I dynamically effect the transform property in a similar way?
I’m used to programming in Processing, Monogame, Unity, etc, and this sort of thing works fine in those environments – flipping a variable to a negative number and then using it to change direction. Is there some limitation in the way scripting works in AE that means this just won’t work?
Any help greatfully appreciated!
Thanks in advance.