Skip to main content
Participant
October 13, 2021
Answered

Bounce Expression error on Path morphing?

  • October 13, 2021
  • 3 replies
  • 5017 views

Hello

 

Would like to know if I'm doint anything wrong, because I'm trying to make my shape bounce when morphed, but I get an error message.

How could I solve this issue? 

 

Thank you!

 

Correct answer Dan Ebberts

This path overshoot expression might be helpful in some situations. It assumes that the number of points doesn't change and it doesn't apply any bounce to the tangents.

freq = 3;
decay = 5;
val = value;
if (numKeys > 0){
  n = nearestKey(time).index;
  if (time < key(n).time) n--;
  if (n > 0){
    path = thisProperty;
    pNow = path.points(time);
    p1 = path.points(key(n).time);
    p0 = path.points(key(n).time - thisComp.frameDuration);
    p = [];
    dur = thisComp.frameDuration;
    t = time - key(n).time;
    for (i = 0; i < p1.length; i++){
      amp = (p1[i] - p0[i])/dur;
      w = freq*Math.PI*2;
      p.push(pNow[i] + amp*(Math.sin((t)*w)/Math.exp(decay*(t))/w));
    }
    val = createPath(p, path.inTangents(), path.outTangents(), path.isClosed())
  }
}
val

3 replies

Dan Ebberts
Community Expert
Dan EbbertsCommunity ExpertCorrect answer
Community Expert
October 13, 2021

This path overshoot expression might be helpful in some situations. It assumes that the number of points doesn't change and it doesn't apply any bounce to the tangents.

freq = 3;
decay = 5;
val = value;
if (numKeys > 0){
  n = nearestKey(time).index;
  if (time < key(n).time) n--;
  if (n > 0){
    path = thisProperty;
    pNow = path.points(time);
    p1 = path.points(key(n).time);
    p0 = path.points(key(n).time - thisComp.frameDuration);
    p = [];
    dur = thisComp.frameDuration;
    t = time - key(n).time;
    for (i = 0; i < p1.length; i++){
      amp = (p1[i] - p0[i])/dur;
      w = freq*Math.PI*2;
      p.push(pNow[i] + amp*(Math.sin((t)*w)/Math.exp(decay*(t))/w));
    }
    val = createPath(p, path.inTangents(), path.outTangents(), path.isClosed())
  }
}
val
Participant
October 14, 2021

Great help! Thanks very much

Community Expert
October 13, 2021

For a path to bounce, you need keyframes and the graph editor. The Speed graph will give you control over acceleration and at least 4 keyframes are required. Starting Position, Maximum deformation, Resting position created just before Maximum Distortion, then a copy of Resting Position pasted after the Maximum Deformation keyframe. Fiddle with the handles. If you need more than one bounce then you need to set interim keyframes.

Mylenium
Legend
October 13, 2021

Compound properties such as shape animation cannot be addressed with this kind of expression. Since all the changes to the path are stored in single keyframes, there simply is no way to access velocity for path anchor points. What you seem to want to do would require creating Null objects as path contzrollers and applying the bounce expression to the Nulls' position.

 

Mylenium

Participant
October 14, 2021

Hello 

 

Thanks for help!

Below I have received an expression that really helped me out obtaining the result that I needed. 

 

Have a nice day