# Creative Communities of the World Forums

The peer to peer support community for media production professionals.

• # DeltaTime

2 Members · 8 Posts
• ### Marc Keeling

November 12, 2019 at 5:31 pm

Hey all, I have a small problem I need help with.

In Trapcode Particular there is an offset on X I am animating over time in the turbulence section.
I wish to animate a slider from 1 to -1, to flip the direction the offset is incremented in. Ie I flip the slider to -1, and the X value start counting backwards at the same speed.
I thought it was as simple as multiplying time by the slider, but that doesn’t work as it gives me the negative time value, rather than counting backwards. Is there anyway to do this?

Marc

• ### Walter Soyka

November 13, 2019 at 2:38 pm

I’m not entirely sure I understand. You want the slider to be the amount of increase per frame, relative to the last frame?

So if I start the slider at 1, my values go 0, 1, 2, 3, 4, 5

And then I change slider to -1, the values continue 4, 3, 2, 1, 0, -1?

Walter Soyka
Motion Graphics, Widescreen Events, Presentation Design, and Consulting

• ### Marc Keeling

November 13, 2019 at 3:08 pm

Yeah. Currently when I change slider to -1, it quickly animates from 5 to -6, as it’s tied to the time of the comp.

• ### Walter Soyka

November 13, 2019 at 6:07 pm

After Effects expressions are evaluated instantaneously for each frame, and they don’t have any concept of what happened on the frame before. In order to access previous values, you have to manually recompute and accumulate them.

Code like this will do it:
`delta = effect("Delta")("Slider");`

`var accumulator = value; for (var i = 0; i < timeToFrames(time); i++) { accumulator += delta.valueAtTime(framesToTime(i)); }`

`accumulator`

Use this expression on the value you want to accumulate over time and link “delta” to the slider you are manipulating.

Note that the evaluation of this expression slows over time, because each frame must compute and accumulate the values of all preceding frames.

Walter Soyka
Motion Graphics, Widescreen Events, Presentation Design, and Consulting

• ### Marc Keeling

November 14, 2019 at 12:06 am

Thanks so much! I will give it a try.

• ### Marc Keeling

November 14, 2019 at 5:09 pm

Just wondering… is there another way to continuously animate forward without using time? Time can be a pain when linking comps together

• ### Walter Soyka

November 14, 2019 at 5:18 pm

If you want to use an accumulation technique, you need to consider time.

The expression I shared could be a lot smarter about time, though — starting at the layer’s inPoint instead of assuming that time begins at 0, building in a time offset control if you need to link it to a different clock in another comp, etc.

Walter Soyka
Motion Graphics, Widescreen Events, Presentation Design, and Consulting