Copy link to clipboard
Copied
I'm looking to have a checkbox in the essential graphics that will start an image either right side up, or upside down. I have that part sorted out by pick whipping the expression to the checkbox * 180. If it's checked, it starts upside down. That's the easy part.
Here's my issue:
I want the image to end up right side up, regardless of the starting position. Is there a way to apply an if statement that essentially says "If this starts upside down at keyframe 1, rotate it 180 degrees by keyframe 2. Else don't rotate it at all (because it's fine as is)"
I don't know of a way to apply expressions to a keyframe only, without affecting the overall property along the entire layer.
I would probably also add a duration slider instead of a keyframe for the end position. If you multiply the slider by the frame duration setting the slider to 20 will give you a 20 frame animation. Here is one way to create the expression:
dur = thisComp.layer("Controller").effect("Duration")("Slider") * thisComp.frameDuration;
ctrl = thisComp.layer("Controller").effect("Checkbox Control")("Checkbox");
if (ctrl == 1){
sVal = 180;
}
else{
sVal = 0;
}
t = time - thisLayer.inPoint;
easeOut(t, 0
...
Copy link to clipboard
Copied
I would probably also add a duration slider instead of a keyframe for the end position. If you multiply the slider by the frame duration setting the slider to 20 will give you a 20 frame animation. Here is one way to create the expression:
dur = thisComp.layer("Controller").effect("Duration")("Slider") * thisComp.frameDuration;
ctrl = thisComp.layer("Controller").effect("Checkbox Control")("Checkbox");
if (ctrl == 1){
sVal = 180;
}
else{
sVal = 0;
}
t = time - thisLayer.inPoint;
easeOut(t, 0, dur, sVal, value)
If you want to use a keyframe then you only need one placed at the point where the rotation ends. This would allow. you to customize the easing with the graph editor and the expression would look like this:
ctrl = thisComp.layer("Controller").effect("Checkbox Control")("Checkbox");
if (ctrl == 1){
sVal = 180;
}
else{
sVal = 0;
}
t = time - thisLayer.inPoint;
easeOut(t, 0, key(1).time, sVal, value)
These expressions will give you a counter-clockwise rotation. To make the rotation clockwise just change line three to read sVal = - 180;
Copy link to clipboard
Copied
Thank you for your thorough and thoughtful response.
The gap in my knowledge was the easeOut function. Now that I know that exists, I'll be able to better animate through expressions. Much appreciated!