## Expression for offset and bounce

Moderators: Disciple, zlovatt

heartwoodmedia
Posts: 1
Joined: October 20th, 2005, 12:49 pm
I'm trying to simulate the look of a slot machine. I'm using the offset filter with a strip of images, and it's working well. What I can't get it to do is give me that bounce.

Can anyone point me in the direction of where to begin with an expression to do this? I'm an absolute neophyte when it comes to expressions.

Thanks,
Chris
goldomega
Posts: 9
Joined: August 12th, 2005, 8:54 am
Location: Rochester, NH
I would check Dan Ebberts' amazing expression site Motionscript.com.

After going through the basics of expressions, check out the section on physical simulations:

http://www.motionscript.com/mastering-e ... ics-3.html

Using sine waves and exponential decay, you should be able to build a very decent bounce for your offset effect.
goldomega
Posts: 9
Joined: August 12th, 2005, 8:54 am
Location: Rochester, NH
If you need a fast solution, set two keyframes for the spinning motion, and try this expression on the 'shift center to' property of Offset:

freq = 10;
amplitude = 25;
decay = 5.0;

t = time - key(numKeys).time;
x = scale[0] + amplitude*Math.sin(freq*t*2*Math.PI)/Math.exp(decay*t);
if (time < key(numKeys).time)
thisProperty else [thisProperty[0], thisProperty[1]+x]

After your last keyframe, there should be a fairly decent decaying bounce. Adjust your freq, amplitude and decay settings as needed.