Highlighted

Explorer ,
May 11, 2017

Copied

I'm usually pretty good with expressions, but I'm really stumped on this one:

For the sake of keeping it simple, let's say I have:

1. A layer

2. A null object with a slider

I want my layer to slide in (x position only) from Point A, to Point B, pause on Point B for a few seconds, then slide back to Point A.

Here's the challenge: I want Point B to be controlled by the slider, but I always want Point A to be the same exact starting/ending point. (say 0, for the sake of simplicity). So the animation should go:

0 to X, then X back to 0, where X is the value driven by the slider.

Hope this makes sense. Thank you in advance to anyone who might be able to help.

You need slight modification (the thing called C replaces A at the very end):

`t0 = inPoint; transitionDur = 3; holdDur = 5; // A, B : start/end value for the x coordinate A = valueAtTime(0)[0];    // or some constant numeric value like 0 B = thisComp.layer("Null 1").effect("Slider Control")(1).value;C = 50;y = value[1];                // or some constant numeric value like 0 t1 = t0+transitionDur; t2 = t1+holdDur; t3 = t2+transitionDur; x = (time<=t1) ? linear(time, t0, t1, A, B) : linear(time, t2, t3, B, C); [x,y];`

@foughtthelaw : You need to enable the "Advanced Editor", then >>(insert)>(SyntaxHighlightning)>javascript

Xavier

Topics

Expressions

Views

2.7K

Likes

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Explorer ,
May 11, 2017

Copied

I'm usually pretty good with expressions, but I'm really stumped on this one:

For the sake of keeping it simple, let's say I have:

1. A layer

2. A null object with a slider

I want my layer to slide in (x position only) from Point A, to Point B, pause on Point B for a few seconds, then slide back to Point A.

Here's the challenge: I want Point B to be controlled by the slider, but I always want Point A to be the same exact starting/ending point. (say 0, for the sake of simplicity). So the animation should go:

0 to X, then X back to 0, where X is the value driven by the slider.

Hope this makes sense. Thank you in advance to anyone who might be able to help.

You need slight modification (the thing called C replaces A at the very end):

`t0 = inPoint; transitionDur = 3; holdDur = 5; // A, B : start/end value for the x coordinate A = valueAtTime(0)[0];    // or some constant numeric value like 0 B = thisComp.layer("Null 1").effect("Slider Control")(1).value;C = 50;y = value[1];                // or some constant numeric value like 0 t1 = t0+transitionDur; t2 = t1+holdDur; t3 = t2+transitionDur; x = (time<=t1) ? linear(time, t0, t1, A, B) : linear(time, t2, t3, B, C); [x,y];`

@foughtthelaw : You need to enable the "Advanced Editor", then >>(insert)>(SyntaxHighlightning)>javascript

Xavier

Topics

Expressions

Views

2.7K

Likes

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
May 11, 2017 0
9 Replies 9
Engaged ,
May 11, 2017

Copied

keyframe your A and B position and try this on your position value

valueAtTime(linear(s,0,numKeys,key(1).time,key(numKeys).time))

The slider will now blend between the 2 positions

Likes

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
May 11, 2017 0
Explorer ,
May 11, 2017

Copied

Unfortunately, this didn't quite work. Now my layer x position stays at 0 throughout, no matter what the slider value. Any other ideas?

Thanks again.

Likes

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
May 11, 2017 0
May 11, 2017

Copied

This might be it:

`t0 = inPoint;transitionDur = 3;holdDur = 5;// A, B : start/end value for the x coordinateA = valueAtTime(0)[0];    // or some constant numeric value like 0B = thisComp.layer("Null 1").effect("Slider Control")(1).value;y = value[1];                // or some constant numeric value like 0t1 = t0+transitionDur;t2 = t1+holdDur;t3 = t2+transitionDur;x = (time<=t1) ? linear(time, t0, t1, A, B) : linear(time, t2, t3, B, A);[x,y];`

Xavier

Likes

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
May 11, 2017 0
Engaged ,
May 12, 2017

Copied

how do you get that nice text formatting for your code?

Likes

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
May 12, 2017 0
Explorer ,
May 12, 2017

Copied

Thank you! This is exactly what I needed.

Now, for an added challenge: the scope of the project changed a little, so instead of having the layer move back to its original position (0), now, after pausing on the slider value, it needs to move to a third position, say 50 for example.

So the animation should go:

0 to X, pause, then X to 50. (50 always being constant)

I have admit, I am mostly unfamiliar with what you came up with in your expression. Thanks again for your help!

Likes

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
May 12, 2017 0
May 12, 2017

Copied

You need slight modification (the thing called C replaces A at the very end):

`t0 = inPoint; transitionDur = 3; holdDur = 5; // A, B : start/end value for the x coordinate A = valueAtTime(0)[0];    // or some constant numeric value like 0 B = thisComp.layer("Null 1").effect("Slider Control")(1).value;C = 50;y = value[1];                // or some constant numeric value like 0 t1 = t0+transitionDur; t2 = t1+holdDur; t3 = t2+transitionDur; x = (time<=t1) ? linear(time, t0, t1, A, B) : linear(time, t2, t3, B, C); [x,y];`

@foughtthelaw : You need to enable the "Advanced Editor", then >>(insert)>(SyntaxHighlightning)>javascript

Xavier

Likes

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
May 12, 2017 0
Explorer ,
May 12, 2017

Copied

Thank you very much for all your help! That's exactly what I needed and works perfectly!

Likes

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
May 12, 2017 0
New Here ,
Apr 04, 2020

Copied

Hi, I have a basic rectangular shape with text sliding from left to middle of the screen (x1  to x2), and when it reach it give a shake (Wiggle effect). I have key framed the wiggle effect to do that. I have created null and created controls for color and other parameters. But I don't know how to create a control for the wiggle effect only for the particular period I keyframed for. Played all day .. No luck. Please help me to solve this.

See the file here . https://drive.google.com/open?id=1g1hsfh9clb3ssXCEpIIZ7ci2b5iyjLwS

Likes

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Apr 04, 2020 0
LATEST
Apr 04, 2020

Copied

I just answered this same kind of question in another thread. You can use the inPoint and outPoint of another layer in an if-else statement to turn something on or off. Check out this example:

``````ctrl = thisComp.layer("Null 1");
amp = effect("Slider Control")("Slider");
if (time < ctrl.inPoint)
wiggle(6, amp)
else if (time > ctrl.outPoint)
wiggle (10, amp)
else value``````

This expression is defining ctrl as a layer named "Null 1" in the first line. It is looking for a slider control on the same layer and calling that variable a. The if statement says if the time is less than the in point of ctrl (Null 1) then wiggle 6 times a second whatever the value in the slider is but if the time is greater than the out point of Null 1, wiggle 10 times a second whatever the value of the slider is, but in between the in and out point of the ctrl layer (else) just use the value of this property even if it has keyframes. It's pretty straight forward.

Likes

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Apr 04, 2020 0