float object up and down

Started by
4 comments, last by pcmaster 4 years, 7 months ago

how to do floating physics, what is the calculation per frame,

by floating i do not mean water floating but hover/air floating where the object is bouncing up and down like say a floating/flying island.

Whats the per frame computation of it?

 

thank you in advance

Advertisement

For example using the sine or the cosine function.

position = base_position + ( amplitude * sin(speed * absolute_time) )

where base_position would be the point around which it'll oscilate, amplitude is how much plus/minus around it it will oscilate (sine and cosine operate on all real numbers and return values [-1; +1]), speed scales the 'animation' speed (when 1, it'll do 1 'loop' in 2PI seconds) and absolute_time is your system time, for example.

 

5 hours ago, cebugdev said:

[...] bouncing up and down like say a floating/flying island.

I don't think I've ever seen a floating/flying island. Can you point us to some reference video of what you are trying to achieve?

Do you want to achieve something like a  spring joint in all three axises on an object? This will couse it to bounce when interacted with a force and returning to original position when force gets balanced off.

I think OP desires something like this:

395f354a7ebc081604f6e8e7d84d3998.gif

Note that you won't achieve exactly this with my solution, it'll be much more "fluid" but you can experiment with smoothstep for example.

This topic is closed to new replies.

Advertisement