ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

# Random motion/speed around comp then back to original position

FAQ   •   VIEW ALL
 Random motion/speed around comp then back to original position on Nov 5, 2015 at 7:27:22 pm

I have some particles to move around randomly in a scene that loops, so I can't use Particular or other particle simulators. Any suggestions for expressions that will move each piece smoothly and randomly around the comp at varying speeds, returning to it's original position at the end of a specified duration?

 Re: Random motion/speed around comp then back to original positionon Nov 6, 2015 at 12:02:47 am

actually, creating a looping particle system is very easy. search the cow's ae tutorials for 'looping particle' for a straight forward tutorial.

Kevin Camp
Art Director
KCPQ, KZJO & KRCW

 Re: Random motion/speed around comp then back to original positionon Nov 6, 2015 at 12:15:19 am

Ah yes that would work for most particle effects but I need the same particles to each return to their original position as if they are flying in elaborate looped circles. I'm basically simulating fireflies dancing around the screen but they should return to their initial position to complete the loop without having them die off and be replaced by new particles. Is there a script to give random smooth motion around the comp and then return to their original spot, using a seed to ensure each layer is on a different trajectory?

 Re: Random motion/speed around comp then back to original positionon Nov 6, 2015 at 12:54:18 am

you could use a wiggle() expression on one of your firefly layers, but tie the wiggle amount to a slider and keyframe the slider to go from 0, to some amount, then back to 0.

add a slider to your firefly and keyframe it to go from 0 to 500 to 0.

add an expression to the firefly's position property and add this expression:

amount = effect("Slider Control")("Slider");
wiggle(1,amount)

the layer should go from static to flying about and then back to static, resting in the same place that it started.

Kevin Camp
Art Director
KCPQ, KZJO & KRCW

 Re: Random motion/speed around comp then back to original positionon Nov 9, 2015 at 11:41:46 pm

Thanks Kevin, that works pretty well. I used that idea coupled with Dan Ebberts' genius scripting below:
freq = 1;
amp = 110;
loopTime = 3;
t = time % loopTime;
wiggle1 = wiggle(freq, amp, 1, 0.5, t);
wiggle2 = wiggle(freq, amp, 1, 0.5, t - loopTime);
linear(t, 0, loopTime, wiggle1, wiggle2)

I scripted the frequency, amplitude and loopTime to sliders so I could control them across dozens of layers for a random but seamless loop. Thanks everyone!