-
Position value as target of automatized movements
Hello everyone, I’m trying to make an object move to the position determined by the value of the current keyframes, in a sort of automatized way (with an ‘ease’ expression).
In ‘position’ I’ve set the keyframes and the following expression… which doesn’t work :/
The object just pops up in the position of the current keyframe. I can’t figure out what I’m doing wrong. Any ideas? Thanks!
if (numKeys > 0) {
ClosestKeyframe = nearestKey(time);
if (ClosestKeyframe.time > time){
CurrentKeyframe=key(ClosestKeyframe.index – 1);
} else {
CurrentKeyframe=key(ClosestKeyframe.index);
}
}
if (CurrentKeyframe.index = 1) {
PreviousKeyframe=key(1);
} else {
PreviousKeyframe=key(CurrentKeyframe.index-1);
}
dur=1;
startTime=CurrentKeyframe.time-dur;
endTime=CurrentKeyframe.time;
startValue=valueAtTime(PreviousKeyframe.time);
endValue= CurrentKeyframe.value;
ease(time,startTime,endTime,startValue,endValue)