Skip to main content
Participant
June 28, 2022
Question

How can I add delay to the inertial bounce expression? (HELP!)

  • June 28, 2022
  • 4 replies
  • 1487 views

I'm doing a project where  I have 4 shape layers (A, B, C, D) stacked one on top of the other with a NULL layer as a parent. The null layer is animated in the Y-position, but as the null reaches its last point, I want the other layers to have an inertial bounce with delay (delay the bounce). 

 

I tried this expression on layer A, and it works, however when I put it on layers B, C, and D they are all bouncing at the same time.

 

freq = 1.5; decay = 10; p = parent.transform.yPosition; n = 0; if (p.numKeys > 0){ n = p.nearestKey(time).index; if (p.key(n).time > time) n--; } if (n > 0){ t = time - p.key(n).time; p1 = toWorld(anchorPoint,p.key(n).time); p0 = toWorld(anchorPoint,p.key(n).time - .01); amp = (p1 - p0)/.01; w = freq*Math.PI*2; value + amp*(Math.sin(t*w)/Math.exp(decay*t)/w); }else value

 

 

I hope I'm making sense. 

I will appreciate any feedback. 

Thank you in advance

 

 

This topic has been closed for replies.

4 replies

Joost van der Hoeven
Community Expert
Community Expert
June 29, 2022

You have the attention of three reknown expression experts @dnnmarr, did their suggestions help you?

Mylenium
Legend
June 29, 2022

You would simply have to add a temporal offset to the p.key(n).time for each layer. Something like p.key(n).time+framesToTime(5).

 

Mylenium

dnnmarrAuthor
Participant
June 29, 2022

Mylenium, thank you for your response. I solve my problem with this expression

m = index-1; //index # of the animated layer (thisComp.("masterLayer"))

//create control layer with 3 sliderControls (d = delay, x = xOffset, y = yOffset)
d= //sliderControl
p= transform.position.valueAtTime(time-d*m); //thisComp.("masterLayer").transform.position
x = //sliderControl
y = //sliderControl

[p[0] + x*m,p[1] + y*m]

  

Community Expert
June 29, 2022

I would create an expression that performed the entire movement based on the layer in and out point, then stagger the layers in the timeline, so they came in one at a time. 

 

You could also use the layer index as a multiplier for the move start, speed, or end of move time.

 

You could also set up a second slider to use as a delay slider. 

 

I have a lot of animation presets that move layers in and out of the frame. They almost all use layer in and out points for the move. You put a layer where you want it to end up, add the preset, which usually adds a bunch of sliders and check boxes, then sequence the layers, and you're done.

 

I don't have time to work it out for you right now, but if you want all of the layers to move in following the parent, then bounce to a stop at different times, then the move timing will have to be controlled by the time of the last parent keyframe + a time delay. 

 

Here's my FlyInBounceFlyOut expression. You might get some ideas from the language. You'll have to add some sliders and a checkbox to make it work, but it might give you some ideas.

sif = effect("slideIn Frames")("Slider");
sof= effect("slideOut Frames")("Slider");
// find in and out pointOfInterest
stime = time - inPoint;
inTime = sif * thisComp.frameDuration;
	if (effect("Match SI SO")("Checkbox") == 0) {
	outTime = sof * thisComp.frameDuration;
	}
	else if (effect("Match SI SO")("Checkbox") == 1) {
	outTime = inTime;
	}
// Fix  layer size when scaled
sf = scale - [100, 100];
xSize = width + (width * sf[0]/100);
ySize = height + (height * sf[1]/100);
realSize = [xSize, ySize];
// Set Positions
spx = 0 - realSize[0] + realSize[0]/2 ;
rstx = value [0];
rsty = value[1];
epy = thisComp.height + realSize[1] - realSize[1]/2;
// create movement 
freq = effect("bounce Frequency")("Slider");
        amplitude = effect("bounce Amplitude")("Slider");
        decay = effect("bounce Decay")("Slider");
    posCos = Math.abs(Math.cos(freq*time*2*Math.PI));
	nt = time-inPoint;
    y = amplitude*posCos/Math.exp(decay*nt);
moveIn = Math.min(linear(stime,0,inTime,spx  ,rstx-y));
moveOut = Math.min(easeIn(time,outPoint - outTime,outPoint - thisComp.frameDuration,rsty ,epy));
[moveIn, moveOut]
dnnmarrAuthor
Participant
June 29, 2022

Thank you for your response. I had difficulty wording my problem. I took a look at your expression, and it definitely helped me to understand how certain things work, however, I found an easier solution to achieve exactly what I wanted. 

Dan Ebberts
Community Expert
Community Expert
June 28, 2022

What defines how long the delay is for each layer?

dnnmarrAuthor
Participant
June 28, 2022

I don't know if I understood your question, but I was hoping to use a slider control with a time expression. I really don't know how to work around this.

[When the null stop, the children layers overlap each other with time delay]