Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Bobbing in Water REDUX

  • Bobbing in Water REDUX

    Posted by David Rodriguez on June 20, 2008 at 12:09 pm

    I am using the expression for undulation found at Dan Ebberts’ site

    on position the following.

    xAmp = 3; //height of undulations (pixels)
    xFreq = .3; //undulations per second
    xSpeed = 150; //speed of wave (pixels per second)

    wl = xSpeed/xFreq; //wavelength (pixels)
    phaseOffset = ((position[0]%wl)/wl)*2*Math.PI;
    y = xAmp*Math.sin(2*Math.PI*xFreq*time + phaseOffset);
    value + [0,y]

    on rotation the following.

    xFreq = .3; //undulations per second
    xSpeed = 150; //speed of wave (pixels per second)
    damping = 15; //undulation damping factor

    wl = xSpeed/xFreq; //wavelength (pixels)
    phaseOffset = ((position[0]%wl)/wl)*2*Math.PI;
    theta = Math.atan(Math.cos(2*Math.PI*xFreq*time + phaseOffset));
    radiansToDegrees(theta)/damping;

    What I need is for the object to sway left and right 50 pixels or so.
    I have tried applying a one position only wiggle to a null and parenting my object to that but the motion doesn’t seem natural as the two expressions sometimes conflict and cancel out each others motion. Is there any way to incorporate the left/right movement I need into this existing expression that works almost perfectly for my needs.

    Any help is much appreciated.

    David Rodriguez replied 17 years, 11 months ago 3 Members · 4 Replies
  • 4 Replies
  • Kevin Camp

    June 20, 2008 at 3:28 pm

    you could try adding an the same y expression as the x component for position…

    just change the last line to:

    value + [y,y]

    if needed you could add a multiplier to the x component, something like this:

    value + [4*y,y]

    or you might try just offsetting the anchor point, moving it down… this will change how the rotation expression effect the rotation of the layer, and create side to side movement. that actually might be the easiest and most natural way to do what you are looking for…

    Kevin Camp
    Senior Designer
    KCPQ, KMYQ & KRCW

  • David Rodriguez

    June 20, 2008 at 3:42 pm

    This works! Thank You.

  • Trent Armstrong

    June 20, 2008 at 3:43 pm

    Hey! I modified what you had just a little to get an X parameter. You’ll see the //–NEW section in the code.

    Trent

    xAmp = 3; //height of undulations (pixels)
    xFreq = .3; //undulations per second
    xSpeed = 150; //speed of wave (pixels per second)

    wl = xSpeed/xFreq; //wavelength (pixels)
    phaseOffset = ((position[0]%wl)/wl)*2*Math.PI;
    y = xAmp*Math.sin(2*Math.PI*xFreq*time + phaseOffset);

    //–NEW

    swayAmp = 100; //amplitude of sway
    swayFreq = .25; //frequency of sway
    x = swayAmp * Math.sin(time * swayFreq);

    //—–
    value + [x,y]

    Trent Armstrong – Creative Cow Leader
    https://www.dallasaeug.com

  • David Rodriguez

    June 20, 2008 at 3:55 pm

    That works very very well, thank you!

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy