Jump to content
  • Advertisement
cebugdev

float object up and down

Recommended Posts

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

Share this post


Link to post
Share on other sites
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.

 

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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.

Edited by pcmaster

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!