Copy link to clipboard
Copied
Hello,
I have two expressions that both work independently that I am trying to combine to use on the same layer.
The first one is a Z space zoom effect:
zoom = 5000; //distance to zoom
trans = 4; // transition time in frames
trans = trans * thisComp.frameDuration;
inTrans = easeIn(time, inPoint, inPoint + trans, [0,0,zoom], [0,0,0]);
outTrans = easeOut(time, outPoint, outPoint - trans*2, [0,0,0], [0,0,zoom]);
value+ inTrans - outTrans
And the second is an overshoot expression:
freq = 3;
decay = 5;
amp = 80;
n = 0;
if (numKeys > 0){
n = nearestKey(time).index;
if (key(n).time > time) n--;
}
if (n > 0){
t = time - key(n).time;
amp = velocityAtTime(key(n).time - .001);
w = freq*Math.PI*2;
value + amp*(Math.sin(t*w)/Math.exp(decay*t)/w);
}else
value
This is my current attempt at combining the two, but I cant get it working. Thanks in advance for the help!
zoom = 5000; //distance to zoom
trans = 4; // transition time in frames
trans = trans * thisComp.frameDuration;
freq = 3; decay = 1;
inTrans = easeIn(time, inPoint, inPoint + trans, [0,0,zoom], [0,0,100]);
outTrans = eaoint, outPoint - trans*1, [0,0,0], [0,0,zoom]);
n = nearestKey(time).index;
amp = velocityAtTime(key(n).time - .001);
t = time - inPoint;
w = freq*Math.PI*2;
value + inTrans - outTrans + amp*(Math.sin(t*w)/Math.exp(decay*t)/w);
Copy link to clipboard
Copied
I'm not clear what you are hoping to achieve. You totally nixed the conditional statemnets to retrieve the keyframe info, so this cannot work - the evaluation condition simply is never valid. That being said, the "trans" stuff would have to be applied as a filter curve to the result of the overshoot expression, not added or subtracted. In effect this simply means where "time" is used in the zoom expression's easIn() and easeOut() you fill in the result of your overshoot. It's a simple case of modulating one result with another. Of course it may require some tweaking, but it's to ealry in the morning for me to realyl get into it...
Mylenium
Copy link to clipboard
Copied
This might work:
zoom = 5000; //distance to zoom
trans = 4; // transition time in frames
trans = trans * thisComp.frameDuration;
if (time < inPoint+trans){
value + easeIn(time, inPoint, inPoint + trans, [0,0,zoom], [0,0,0]);
}else if (time > outPoint - trans*2){
value - easeOut(time, outPoint, outPoint - trans*2, [0,0,0], [0,0,zoom]);
}else{
freq = 3;
decay = 5;
amp = 80;
n = 0;
if (numKeys > 0){
n = nearestKey(time).index;
if (key(n).time > time) n--;
}
if (n > 0){
t = time - key(n).time;
amp = velocityAtTime(key(n).time - .001);
w = freq*Math.PI*2;
value + amp*(Math.sin(t*w)/Math.exp(decay*t)/w);
}else{
value;
}
}
Dan
[EDIT] This is probably better:
freq = 3;
decay = 5;
amp = 80;
n = 0;
if (numKeys > 0){
n = nearestKey(time).index;
if (key(n).time > time) n--;
}
val = value;
if (n > 0){
t = time - key(n).time;
amp = velocityAtTime(key(n).time - .001);
w = freq*Math.PI*2;
val += amp*(Math.sin(t*w)/Math.exp(decay*t)/w);
}
zoom = 5000; //distance to zoom
trans = 4; // transition time in frames
trans = trans * thisComp.frameDuration;
if (time < inPoint+trans){
val += easeIn(time, inPoint, inPoint + trans, [0,0,zoom], [0,0,0]);
}else if (time > outPoint - trans*2){
val -= easeOut(time, outPoint, outPoint - trans*2, [0,0,0], [0,0,zoom]);
}
val
Dan