Skip to main content
Peter J Kovacs
Inspiring
March 18, 2013
Question

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

  • March 18, 2013
  • 5 replies
  • 94555 views

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

5 replies

artichoked
Inspiring
February 3, 2022

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

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

New Participant
May 16, 2020

HOW CAN I STOP THIS?

Brainiac
July 4, 2020

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

New Participant
August 31, 2018

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

New Participant
February 13, 2018

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?

ericsten
Inspiring
March 16, 2018

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

Dan Ebberts
Brainiac
March 18, 2013

Try this:

amp = 100;

freq = 1;

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

value + [0,y,0]

Dan

New Participant
December 19, 2016

Hi Dan,

Please can you tell me which wiggle preset you use?

Many thanks,

Lisa

Dan Ebberts
Brainiac
June 2, 2017

Hi Dan - your solution is a lifesaver. Pretty new still to a Position Express - if I wanted to do a horizontal shake back and forth rather than up and down like your code, what would that look like? I tried subbing in X for Y values but that didn't work. Much appreciated!

Julie


This should work:

amp = 100;

freq = 1;

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

value + [x,0,0]

Dan