Skip to main content
MarcoBarbosa
Participant
May 27, 2016
Answered

Floating Expression

  • May 27, 2016
  • 1 reply
  • 2741 views

Greetings community,

i found an expression that makes a floating animation with consistant oscillations.

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]

This expression does the oscillations only on the Y axes.

My question:

Is there a way to make the expression do the oscillation not just on Y, but also on the X axes at the same time?

This topic has been closed for replies.
Correct answer Mylenium

Simply re-use the y variable twice in the last line: value + [y,y]. It's not going to look particularly good, though, since it will effectively only "rotate" the effect by 45 degrees. You should duplicate the wave code and use different values for the x coordinates.

Mylenium

1 reply

Mylenium
MyleniumCorrect answer
Legend
May 27, 2016

Simply re-use the y variable twice in the last line: value + [y,y]. It's not going to look particularly good, though, since it will effectively only "rotate" the effect by 45 degrees. You should duplicate the wave code and use different values for the x coordinates.

Mylenium