Skip to main content
Participant
March 8, 2023
Question

separated scale dimensions to slider

  • March 8, 2023
  • 2 replies
  • 531 views

Hello dear AE people!

 

I have a box (solid) with separated scale dimensions. Both dimension's values are connected to a separate sliders (X and Y)

Each slider should be animated with 4 keyframes.

Example: X slider value going from 100 to A and back from A to 100, and Y slider value going from 100 to B and back from B to 100.

 

Then I need to have a null object with 2 sliders (A and B). The idea is to be able to type in the numer into each of the sliders on the null, and those numbers will adjust the values of the second and third keyframes of the correcponding sliders on the solid.

Example: typing in 120 in to the slider A on the null, will adjust the second and the third keyframes values on the solid, which are connected to the X value. And the same goes for the B, which will adjust the second and the third keyframes of the Y value. 

 

Is there any way to make this possible?

 

This topic has been closed for replies.

2 replies

Community Expert
March 9, 2023

I'm not sure I completely understand what you are trying to do. 

 

If you want to ease from one keyframe to another or ease over time you need to define the time of the keyframe and the duration of the easing. 

 

For example:

 

t = time - key(time);
v1 = ease(t, 0, 1, 100, 200);
v2 = ease(t, 1, 2, 200, 100);

value + V1 + V2

 

This expression will start changing values at the start time of the first keyframe and change the value from 100 to 200 over 1 second; then it will ease again from 200 back to 100 over the next second. 

 

It looks like you want to use time as t, start changing the first variable when time passes the first keyframe, and keep changing the value until time equals the second keyframe. I don't see any reason for the if statements. I think that something as simple as this would do it:

 

t1 = key(1).time;
t2 = key(2).time;
t3 = key(3).time;
t4 = key(4).time;
t = time;
def = value;
nVx = thisComp.layer("Null").effect("A")("Slider") - def[0];
nVy = thisComp.layer("Null").effect("B")("Slider") - def[1];
x = easeOut(t, t1, t2, 0, nVx);
x2 = easeIn(t, t3, t4, nVx, 0);
y = easeOut(t, t1, t2, 0, nVy);
y2 = easeIn(t, t3, t4, nVy, 0);
if (t < t3)
	 def + [x, y]
else
	def + [x2, y2]

 

If you apply that expression to the scale of a layer, and the layer starts out at 100, 100 and the Slider A is 150 and slider B is 160, the scale will ease from 100 to 150 between the first and second keyframes, then hold until the third keyframe and return to 100 in x. The Y value will start at 100 and increase to 160 by the second keyframe, then hold until the third keyframe and ease back to 100 in y. 

 

Is that what you want to accomplish?

alexkoganAuthor
Participant
March 14, 2023

Hi Rick! Thank you very much for looking into it. Your expression indeed does make more sense then mine and works perfectly for what i need. However, I have tested it with some different values and it seems like when the A number is below 200 some bouncing animation occurs (guess this is because of easing). Do you have an idea how this can be fixed?

alexkoganAuthor
Participant
March 8, 2023

So that is the expression I've been able to get to work:

if(numKeys>1){

t1 = key(1).time;
t2 = key(2).time;
t3 = key(3).time;
t4 = key(4).time;
v1 = 100;
v2 = thisComp.layer("Null").effect("A")("Slider");
v3 = thisComp.layer("Null").effect("A")("Slider");
v4 = 100;

if (time < t2){
easeOut(time, t1, t2, v1, v2);
} else {
if(time < t3){
ease(time,t2, t3, v2, v3);
}else{
easeIn(time, t3, t4, v3, v4);
}
}
}else value;

 

The question is it possible to add some easing to the animation? As it seems that the expression ignores the original easing and the animation is completely linear.