Skip to main content
Peter J Kovacs
Inspiring
Mar 18, 2013 4:03 PM UTC
Question

How to create a simple bobbing up and down motion expression?

Hi, I have a 3D object that I want to continuously bob up and down but I'm having trouble finding an expression to do this.

I would use wiggle on the Z except wiggle creates random motion and I need consistant up and down oscillations.

It seems simple but I can't figure it out... any ideas? Thanks.

-Pete

33 replies

artichoked
Inspiring
Feb 3, 2022 6:46 PM UTC

If you get an error, try adding curly brackets to the if/else statement:

if (t < StartTime) {value;} else {(value + [x,0,0])}

Translate
Participant
May 16, 2020 1:51 AM UTC

HOW CAN I STOP THIS?

Translate
Community Expert
Jul 4, 2020 3:50 AM UTC

Stop or start the effect by controlling amp and freq with sliders then animate the sliders.

Translate
Participant
Aug 31, 2018 12:37 PM UTC

Hi all,

The expression worked great. But i have no idea on if it is possible to decelerate the "bobbing/bopping" motion.

Do i need to adjust the value or frequency?

Thanks guys! x

Translate
Participant
Feb 13, 2018 5:23 AM UTC

Hey guys, sorry to revive this but the expression is really great. I'm trying to use it for the z-axis and so far it worked the only thing I'm stuck with is how to create only positive values for the amplitude. Any idea on how to do this?

Translate
ericsten
Inspiring
Mar 16, 2018 3:05 AM UTC

Sorry for the late response.

One way to achieve this is by adding Math.abs() to your expression which will return the absolute values instead of true values (aka negative numbers get switched to positive).

Z=Math.abs(amp*Math.sin(time*freq*Math.PI*2));

- Eric

Translate
Dan Ebberts
Community Expert
Community Expert
Mar 18, 2013 7:44 PM UTC

Try this:

amp = 100;

freq = 1;

y = amp*Math.sin(time*freq*Math.PI*2);

value + [0,y,0]

Dan

Translate
Peter J Kovacs
Inspiring
Mar 18, 2013 8:20 PM UTC

Wow Dan, that works perfectly... thanks for the help!

It would be cool if wiggle had an option to control the randomness so I can get the same results as your expression.

-Pete

Translate