# Gravity / Floating Point - Meters / Question

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

## 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 on other sites
mistake in timer code, or too big G, or nonzero initial velocity, or something similar.

##### 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 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 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

• ### What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

• 13
• 9
• 15
• 14
• 46
• ### Forum Statistics

• Total Topics
634060
• Total Posts
3015300
×