Jump to content
  • Advertisement
Sign in to follow this  
Yeti-Smasher

Gravity / Floating Point - Meters / Question

This topic is 4918 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am working on a program that will allow a user to set the height of a object (a cube for right now) and rotate it as they please. Once they are ready they can drop the cube and watch the affect of gravity / collision / and other rotational aspects. The question I have is that I have the gravity idea working by using a timer and applying the acceleration each time the function is called by using the basic physics equation ( (v0)*t + .5*g*t^2) ) It works and the result looks like some sort of acceleration is taking place. My problem is though that the height I set as a float does not represent the actual height it would be in meters. say I set a float to 20 ( to represent 20 meters ) falls in a time more equal to say a height of 2 meters. While setting height to 200.0f would result in a time of an object falling from the height of 20 meters. Any ideas why this may be happening.. I am using directx 9.0c and C++ <Yeti-Smasher>

Share this post


Link to post
Share on other sites
Advertisement
mistake in timer code, or too big G, or nonzero initial velocity, or something similar.

Share this post


Link to post
Share on other sites
Quote:

using the basic physics equation ( (v0)*t + .5*g*t^2) )


I couldn't tell from your post, but if you're using this equation to update your velocity that's the problem. Remember that velocity can be calculated by using v = v0 + (a*t) and position is y = y0 + v0*t + 0.5*a*t^2 then just make sure to get all the signs right so it doesn't fall up. Good luck.

Share this post


Link to post
Share on other sites
What is g? That determines your units.

If the units are meters and seconds, g = 9.8 m/s2.
If the units are feet and seconds, g = 32 ft/s2.

On the other hand, you didn't say how long it actually took to fall. It only takes about 2 seconds to fall 20 meters.

Share this post


Link to post
Share on other sites
To get the position yes I am using the equation y = y0 + v0*t + 0.5*a*t^2. Or broken down to y = 0.5*a*t^2 because starting position will be the height but in this case i starting at 0 while the init velocity is also 0. About the time i get for the height of 20.0f is about .77 secs. a =9.8m/s^2

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!