Skip to main content
Known Participant
October 31, 2022
Answered

Animation In/Out separately

  • October 31, 2022
  • 2 replies
  • 247 views

Hi guys,

 

I am currently trying to add an expression to my animations and use two different  Checkbox for enable/disable In and Out animations, separately.

 

This is what I tried, but is not working:

var animationOnOff = thisComp.layer("control").effect("Animation In")("Checkbox");
if (animationOnOff == 1) {
value;
}else{
if(numKeys>1){

t1 = key(1).time;
t2 = key(2).time;
v1 = 100
v2 = 100
} else {value}
;
}

var animationOnOff = thisComp.layer("control").effect("Animation Out")("Checkbox");
if (animationOnOff == 1) {
value;
}else{
if(numKeys>2){

t3 = key(3).time;
t4 = key(4).time;
v3 = 100
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


I will try to explain my project a bit:

 

I have 4 keyframes, 2 for the 'In Animation' and 2 for 'Out Animation'.

I want to link them to their Checkboxs so I can turn On/Off the animations separately.

 

I hope you can help me fix the expression

 

 

 

Thanks!

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

I think this does what you want:

if (numKeys >= 4){
  ctrl = thisComp.layer("control");
  if (time < key(2).time){
    ctrl.effect("Animation In")("Checkbox").value ? value : 100;
  }else{
    ctrl.effect("Animation Out")("Checkbox").value ? value : 100;
  }
}else
  value

2 replies

Dan Ebberts
Community Expert
Dan EbbertsCommunity ExpertCorrect answer
Community Expert
October 31, 2022

I think this does what you want:

if (numKeys >= 4){
  ctrl = thisComp.layer("control");
  if (time < key(2).time){
    ctrl.effect("Animation In")("Checkbox").value ? value : 100;
  }else{
    ctrl.effect("Animation Out")("Checkbox").value ? value : 100;
  }
}else
  value
Known Participant
October 31, 2022

It does, thank you very much!

Mylenium
Legend
October 31, 2022

Of course this won't work. You cannot call both variables "animationOnOff" or the second will simply override the first. Likewise, it makes no sense if the values used in each of the ease anaimations are 100%. AE will do the math, it just won't show up because the result is always the same. v1 and v4 surely are meant ot be zero or something.

 

Mylenium

Known Participant
October 31, 2022

Oh god, silly me, I haven.t realized!

 

Thanks 🙂