Discussion:
wiggle only in a locked direction
(too old to reply)
s***@adobeforums.com
2006-11-25 17:32:22 UTC
Permalink
Hello.

I'm using wiggle expression to the screen shake after an explosion. As i understand the 'amp' value determines the random value range in a random direction from the center point. However i'd like to make it that the direction is locked to whatever i want (lets say an angle of 45°).

I searched the help files and i couldnt come up with anything usefull.

Any idea how i would solve this?

Thanks.
D***@adobeforums.com
2006-11-25 23:21:58 UTC
Permalink
Are you applying your wiggle expression to position? It sounds like you're applying it to rotation, which doesn't make sense to me..

To apply it to only posy, it's easy. For 2d position, it's represented as a 2 value array, such as [360, 243]. You can use a variable instead. So:

y = (your wiggle expression);
[360, y]

Hopefully that helps you..
D***@adobeforums.com
2006-11-26 00:54:31 UTC
Permalink
Give this a try:

freq = 5; // wiggles per second
amp = 100; // wiggle amplitude (pixels)
angle = 45; // wiggle angle (degrees)

w = wiggle(freq, amp) - value;
rads = degreesToRadians(angle);
x = w[0]*Math.cos(rads);
y = w[0]*Math.sin(rads);
value + [x, y]

Dan
s***@adobeforums.com
2006-11-26 01:01:08 UTC
Permalink
Thanks a bunch :)
I'm pretty new to expressions, and i had no idea programming and editing are connected this much.

What i mean by the 45° angle: lets say that y direction represents 90° and x directions represents 0°, and i'd like to make it under the angle of 45° (diagonally).

I'd do it:

y = ...;
[y + a, y]

(a - the difference between width and height)

So i guess you'd just have to play around with separate wiggle expressions.
s***@adobeforums.com
2006-11-26 01:55:53 UTC
Permalink
Seems like dan gave a more scientific solution :)

Thanks guys

Continue reading on narkive:
Loading...