-
Bobbing in Water REDUX
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 factorwl = 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.