Skip to main content
Participant
December 23, 2024
Answered

Controlling the Speed of offset Turbulence

  • December 23, 2024
  • 1 reply
  • 359 views

Hi, I have a solid with fractal noise, I want the noise always going downward so the first thing that comes to my mind is using the offset turbulence parameter and increasing the Y property with the "time" expression. I also want to control the speed of movement so I added a slider control to the same solid and called it "Speed". I use this code on offset turbulence but the problem is when I animate the Speed from 10 to 5, the movement should go downward with a slower speed but it goes UP, I also make a chart to show the Y changes. I don't know what is the problem. is my math incorrect or does the code have issues?
thanks a lot.

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

This article explains what you're seeing:

https://www.motionscript.com/articles/speed-control.html

I've modified the linear keyframe integrator to fit your situation:

spd = effect("Speed")("Slider");
n = spd.numKeys;
if (n > 0 && spd.key(1).time < time){
  accum = spd.key(1).value*(spd.key(1).time - inPoint);
  for (i = 2; i <= n; i++){
    if (spd.key(i).time > time) break;
    k1 = spd.key(i-1);
    k2 = spd.key(i);
    accum += (k1.value + k2.value)*(k2.time - k1.time)/2;
  }
  accum += (spd.value + spd.key(i-1).value)*(time - spd.key(i-1).time)/2;
}else{
  accum = spd.value*(time - inPoint);
}
value + [0,accum]

1 reply

Dan Ebberts
Community Expert
Dan EbbertsCommunity ExpertCorrect answer
Community Expert
December 23, 2024

This article explains what you're seeing:

https://www.motionscript.com/articles/speed-control.html

I've modified the linear keyframe integrator to fit your situation:

spd = effect("Speed")("Slider");
n = spd.numKeys;
if (n > 0 && spd.key(1).time < time){
  accum = spd.key(1).value*(spd.key(1).time - inPoint);
  for (i = 2; i <= n; i++){
    if (spd.key(i).time > time) break;
    k1 = spd.key(i-1);
    k2 = spd.key(i);
    accum += (k1.value + k2.value)*(k2.time - k1.time)/2;
  }
  accum += (spd.value + spd.key(i-1).value)*(time - spd.key(i-1).time)/2;
}else{
  accum = spd.value*(time - inPoint);
}
value + [0,accum]
Participant
December 24, 2024

thanks a lot for the article and the code, it worked perfectly. I didn't think coding in After Effects could be this hard.