Skip to main content
Community Expert
September 24, 2022
Answered

Adding two Ease expressions to the same property.

  • September 24, 2022
  • 2 replies
  • 505 views

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.

This topic has been closed for replies.
Correct answer Dan Ebberts

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]]

 

 

2 replies

Dan Ebberts
Community Expert
Dan EbbertsCommunity ExpertCorrect answer
Community Expert
September 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 + 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]]

 

 

Community Expert
September 24, 2022

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

 

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

Mylenium
Legend
September 24, 2022

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-possible/m-p/13180178

 

Mylenium