• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Adding two Ease expressions to the same property.

Community Expert ,
Sep 24, 2022 Sep 24, 2022

Copy link to clipboard

Copied

I thought I had done this before, but I can't figure it out again.

 

I have four position keyframes on a reference layer. I want to drive another property on another layer using an Ease interpolation method twice, so the moves are in opposite directions. Did you follow that?

 

When I only have 2 keyframes, this expression moves a shape layer background from the left edge of the screen until it fits under the moving text layer as the text layer (ref) moves from right to left.

 

 

ref = thisComp.layer(index -1);
hPad = effect("X Pad")("Slider");
refP = ref.position;
box = ref.sourceRectAtTime();
xSize = content("Rectangle 1").content("Rectangle Path 1").size[0];

totWidth = box.width + box.left;

if(refP.numKeys < 2)
	value;

if(refP.numKeys == 2){
	t = time;
	tMin = refP.key(1).time
	tMax = refP.key(2).time;
	value1 = refP[0] - totWidth - hPad/2;
	value2 = value1 + xSize;
	mov = linear(t, tMin, tMax, value1, value2) - refP[0];
}

[mov, refP[1]]

 

 

I need to add two more position keyframes to the ref layer to move it back to the right and have the shape layer move back to the left. The second part of the ease expression would look like this:

 

 

          {
    t = time;
	tMin = refP.key(3).time;
    tMax = refP.key(4).time;
	value1 = refP[0] - totWidth - hPad/2;
	value2 = value1 + xSize;
	mov = ease(t, tMin, tMax, value2, value1) - refP[0];
}

[mov, refP[1]]

 

 

I have been fiddling around with this for about an hour. I can make the shape layer move in or move out, but I can't get it to move in, stay for a while, and then move out.

 

Any help would be appreciated. If anybody knows, it is Dan Ebberts.

TOPICS
Expressions , How to

Views

178

Translate

Translate

Report

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

correct answers 1 Correct answer

Community Expert , Sep 24, 2022 Sep 24, 2022

Rick, I haven't tested this, but I think you just need to test time vs. the 2nd keyframe time, like this:

ref = thisComp.layer(index -1);
hPad = effect("X Pad")("Slider");
refP = ref.position;
box = ref.sourceRectAtTime();
xSize = content("Rectangle 1").content("Rectangle Path 1").size[0];

totWidth = box.width + box.left;

if(refP.numKeys < 2)
	value;

t = time;
if (t < refP.key(2).time){
	tMin = refP.key(1).time
	tMax = refP.key(2).time;
	value1 = refP[0] - totWidth - hPad/2;
	value2 = value1 
...

Votes

Translate

Translate
LEGEND ,
Sep 24, 2022 Sep 24, 2022

Copy link to clipboard

Copied

You need to normalize the values to fall in ranges between 0 and 1, then you can add and multiply them with the distances. See my example from a two weeks ago that uses this methodology to combine different interpolators:

 

https://community.adobe.com/t5/after-effects-discussions/several-length-operations-to-shape-layers-p...

 

Mylenium

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 24, 2022 Sep 24, 2022

Copy link to clipboard

Copied

Rick, I haven't tested this, but I think you just need to test time vs. the 2nd keyframe time, like this:

ref = thisComp.layer(index -1);
hPad = effect("X Pad")("Slider");
refP = ref.position;
box = ref.sourceRectAtTime();
xSize = content("Rectangle 1").content("Rectangle Path 1").size[0];

totWidth = box.width + box.left;

if(refP.numKeys < 2)
	value;

t = time;
if (t < refP.key(2).time){
	tMin = refP.key(1).time
	tMax = refP.key(2).time;
	value1 = refP[0] - totWidth - hPad/2;
	value2 = value1 + xSize;
	mov = linear(t, tMin, tMax, value1, value2) - refP[0];
}else{
	tMin = refP.key(3).time;
    	tMax = refP.key(4).time;
	value1 = refP[0] - totWidth - hPad/2;
	value2 = value1 + xSize;
	mov = ease(t, tMin, tMax, value2, value1) - refP[0];
}

[mov, refP[1]]

 

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 24, 2022 Sep 24, 2022

Copy link to clipboard

Copied

LATEST

Thank you Mylenium, and Dan Ebberts. Dan, you nailed it. I was making things too complicated, as is my usual workflow.

RickGerard_0-1664039866327.gif

 

Thanks again. I. uploaded a project file if you're interested.

Votes

Translate

Translate

Report

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