ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

"Triggering" a Subcomp with an if-Statement

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Reinhold Hansen
"Triggering" a Subcomp with an if-Statement
on Sep 26, 2018 at 2:30:20 pm

Hey everyone,

I am currently working on a Motion Graphics Project that must be very modular.
For that reason I would like the timing of certain subcomps to be dependand on the x-position of a camera.
What I have is a Camera that moves along the x-Axis, revealing various panels that show text information.
Because the lenght of those text is going to change I want the timing to be triggered by the position of the Camera (as stated above).

The animation of the Text happens inside of a Subcomp, and I would like it to play as soon as the value of the x-Position of the Camera reaches 1080.

What i've done so far is write the following expression into the "time Remap" property of the text animation layer:

trigger = thisComp.layer("Kamera 1").transform.xPosition;

if (trigger >= 1080) { time } else {0}


you can probably see tht my experience with expressions (specifically time related) is quite limited.
Is there any workaround or different approach to this problem?

Thanks in advance!
Reinhold


Return to posts index

Dan Ebberts
Re: "Triggering" a Subcomp with an if-Statement
on Sep 26, 2018 at 8:04:03 pm

Triggering is fairly easy when the triggering event has an easily accessible time associated with it, such as a keyframe, or a marker (or even just a specific time). Triggering when a value reaches a certain level is more complex, because the expression has to loop through past frames to find the most recent time when the value went from below the threshold to above it.

This should be close:


trigger = thisComp.layer("Kamera 1").transform.xPosition;
if (trigger >= 1080){
t = time;
while (t >= thisComp.frameDuration){
t -= thisComp.frameDuration;
if (trigger.valueAtTime(t) < 1080){
break;
}
}
time - t;
}else
0



Dan



Return to posts index

Reinhold Hansen
Re: "Triggering" a Subcomp with an if-Statement
on Sep 27, 2018 at 6:31:32 am

Amazing, it works like a charm!
I expected it to be somewhat of a while-statement, but I'm not fluent enough at all in JavaScript / ECMAScript to figure it out alone.
Thanks a lot.

Reinhold


Return to posts index

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