ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

# Loop Wiggle expression

FAQ   •   VIEW ALL
 Loop Wiggle expression on Apr 10, 2009 at 6:57:52 am

I have a 10 second comp with several layers on it. Each layer has a wiggle expression. When I loop this comp, you can clearly see the difference between the last frame and first frame each time it loops. Is there a way to fix this, so it's seamless?

 Re: Loop Wiggle expressionon Apr 10, 2009 at 3:33:10 pm

Here's one way to do it:

http://www.motionscript.com/design-guide/looping-wiggle.html

Dan

 Re: Loop Wiggle expressionon Apr 12, 2009 at 4:25:37 pm

Awesome! That's exactly what I needed. Thanks!

 Re: Loop Wiggle expressionon Aug 5, 2015 at 4:57:25 pm

How do I use this x,y,z wiggle expression
a =wiggle(0.2,150);
b =wiggle(0.15,160);
c = wiggle(0.2,500);
[a[0],b[1],c[2]]

to go with this expression seemless loop expression

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)

```a =wiggle(0.2,150); b =wiggle(0.15,160); c = wiggle(0.2,500); [a[0],b[1],c[2]] 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)```

 Re: Loop Wiggle expressionon Aug 5, 2015 at 6:01:23 pm

Try this:

loopTime = 3;
t = time % loopTime;
a1 = wiggle(0.2, 150, 1, 0.5, t);
a2 = wiggle(0.2, 150, 1, 0.5, t - loopTime);
b1 = wiggle(0.15, 160, 1, 0.5, t);
b2 = wiggle(0.15, 160, 1, 0.5, t - loopTime);
c1 = wiggle(0.2, 500, 1, 0.5, t);
c2 = wiggle(0.2, 500, 1, 0.5, t - loopTime);
linear(t, 0, loopTime, [a1[0],b1[1],c1[2]], [a2[0],b2[1],c2[2]])

Dan

 Re: Loop Wiggle expressionon Nov 27, 2017 at 9:14:02 am

dan, your looping wiggle expression has been such an asset for me so many times so thank you! i've run into somewhat of a wall with it when being applied to a camera's 'point of interest' in a 3D composition, however.

in the simplest reproduction of my issue, i have a stationary, two-node camera whose 'point of interest' value animates across any given length of time (as few as two keyframes). when i apply your expression to the 'point of interest', i find that it animates completely differently from how it should – it's as if the expression is causing an issue with the keyframed values? when i clear the expression and enter a non-looping, regular wiggle [IE wiggle(2,5);] the animation is restored...any idea why this would be?

thanks so much in advance – it's much appreciated!!

PS: side note, is it possible to set the loop time in fractions of seconds, and how would you do that? would a value of '3.20' loop every 3 seconds and 20 frames?

```freq = 2; amp = 5; 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)```

 Re: Loop Wiggle expressionon Nov 27, 2017 at 5:09:12 pm

>.any idea why this would be?

The looping wiggle expression, as you have it set up, will be a blend of two wiggled segments--one from -3 to 0 seconds and one from 0 to +3 seconds. How well this matches up with your keyframes would just be coincidental. It sounds like you need a different design, tied to your keyframe timing, but I'm not sure what that would be exactly.

>is it possible to set the loop time in fractions of seconds

loopTime is in seconds, so if you want 3 seconds and 20 frames, you could do it like this:

loopTime = 3 + framesToTime(20);

Dan

 Re: Loop Wiggle expressionon Nov 30, 2017 at 10:49:26 pm

hey dan,

i really appreciate you taking the time to comment and help me out, so thanks!

have a good one ☺
winston