Skip to main content
Inspiring
August 8, 2020
Answered

expression will only start at the beginning of an animation

  • August 8, 2020
  • 1 reply
  • 821 views

Hello, I am using this expression; 

freq = 1.0; //oscillations per second
amplitude = 50;
decay = 0.7;

amplitude*Math.sin(freq*time*2*Math.PI)/Math.exp(decay*time)

From this source (the pendulum with decay)http://www.motionscript.com/mastering-expressions/simulation-basics-3.html

I need this expression in the middle of my animation, however, it will only play the animation at the very beginning of my timeline, no matter where I place they keyframes. 
I also tried duplicating the asset with crtl+shift+d so that the animation might start at the split, however this did not work and the animation still played from the beginning, but since the beginning of the animation was cut off, it just resumed in the middle of the animation where the cut was instead of playing the whole expression.
Why is this happening, and how can I fix it? 

This topic has been closed for replies.
Correct answer Dan Ebberts

It depends on how you want to tell it when to start. If you know the time, you could do it like this (it will start at 2 seconds in this example):

 

tStart = 2;
freq = 1.0; //oscillations per second
amplitude = 50;
decay = 0.7;
t = Math.max(time - tStart,0);
amplitude*Math.sin(freq*t*2*Math.PI)/Math.exp(decay*t)

 

Dan

1 reply

Dan Ebberts
Community Expert
Dan EbbertsCommunity ExpertCorrect answer
Community Expert
August 8, 2020

It depends on how you want to tell it when to start. If you know the time, you could do it like this (it will start at 2 seconds in this example):

 

tStart = 2;
freq = 1.0; //oscillations per second
amplitude = 50;
decay = 0.7;
t = Math.max(time - tStart,0);
amplitude*Math.sin(freq*t*2*Math.PI)/Math.exp(decay*t)

 

Dan

kk4pupsAuthor
Inspiring
August 8, 2020

Is there anything I can do if I do not know an exact time? I kind of need to feel it out for exact placement due to the needs of my project, will I just have to experiment one second at a time?
Additionally, what can I do to have the animation start at half a second in, 2 and a half seconds in, and so on?

Mylenium
Legend
August 8, 2020

You can manipulate the tStart variable in a million ways by referencing things like thisLayer.inPoint, markers or simply dialling in values via an expression slider. I would suggest you actually read the online help on the basics and watch some of the tutorials linked there rather than just relying on copy&paste code.

 

Mylenium