Copy link to clipboard
Copied
I am working on lipsync animation using a slider. It was tedious, but I thought of a way to ease the process but I have no idea how.
I want an expression that adds a transition between two same keyframes. The slider I use has 0-100 value btw. I want an expression that works like below
I'm a complete beginner when it comes to expressions. I hope someone will help. Thank you very much in advance.
More like this maybe:
val = value;
if (numKeys > 1){
if (time >= key(1).time && time < key(numKeys).time){
n = nearestKey(time).index;
if (time < key(n).time) n--;
if (n > 0){
if (key(n).value == key(n+1).value){
mid = (key(n).time + key(n+1).time)/2;
v1 = key(n).value;
v2 = v1 - .5;
if (time < mid)
val = linear(time,key(n).time,mid,v1,v2)
else
val = linear(time,mid,key(n+1).time,v2,v1);
}
}
}
}
val
Copy link to clipboard
Copied
Refer to this post as an example for some of the necessary code:
The methodology is pretty much the same, you just need to modify the conditionals. Also check this:
http://www.motionscript.com/design-guide/audio-trigger.html
Mylenium
Copy link to clipboard
Copied
I somehow get how the solution there works. But with my limited understanding, I assume that those only work with 2 keyframes. What I'd like to do is make an expression to work on all keyframes and only with the same value.
I think I know how to do the right "if statement" when it comes to value. But I don't have an idea how to do one where I select only the keyframes I want among all the keyframes.
Also thanks for the audio trigger link, it looks helpful.
Copy link to clipboard
Copied
If you apply an expression, it has to supply a value for each frame, not just at the keyframes. So it's important to specify what it needs to do in every situation. Maybe a marked-up screen shot of what you're trying to do would help.
Copy link to clipboard
Copied
In this image, the two keyframes have the same value of 0.77 and my I idea is decrease the value by 0.5 and make it 0.22 on the part between them. Basically, just like adding another keyframe in between. I am looking for expressions that can do this on the rest of keyframes with the same value.
Sorry, I hope I explained it well.
Copy link to clipboard
Copied
I think this is what you're describing, but I'm guessing it's not what you want:
val = value;
if (numKeys > 1){
if (time >= key(1).time && time < key(numKeys).time){
n = nearestKey(time).index;
if (time < key(n).time) n--;
if (n > 0){
if (key(n).value == key(n+1).value){
val = key(n).value - .5;
}
}
}
}
val
Copy link to clipboard
Copied
Tried this, but the decrease in value was applied from first keyframe instead in between of the two.
Copy link to clipboard
Copied
More like this maybe:
val = value;
if (numKeys > 1){
if (time >= key(1).time && time < key(numKeys).time){
n = nearestKey(time).index;
if (time < key(n).time) n--;
if (n > 0){
if (key(n).value == key(n+1).value){
mid = (key(n).time + key(n+1).time)/2;
v1 = key(n).value;
v2 = v1 - .5;
if (time < mid)
val = linear(time,key(n).time,mid,v1,v2)
else
val = linear(time,mid,key(n+1).time,v2,v1);
}
}
}
}
val
Copy link to clipboard
Copied
Thank you so much Dan! This works.