# What is wrong with my gravity calculation?

Im trying to create a method to calculate the fall time for an object using real formulas. Well I came up with this:

    public static double calculate_fall_time(float height) {
final float GRAVITY = 9.81f;
float h = (1/2)*GRAVITY*2;
float h2 = GRAVITY/GRAVITY;
double t = Math.sqrt(((2*h2)/GRAVITY));

return t;
}


Well I used to this website to compare the results but it wasn't the same. If I have 370 at the input then my program shows 0.4515 but the website is showing around 8,6 seconds.

Does anybody know how I can fix this problem? Thanks in advance :D

NOTE: I know that arcade physics are much more fun but my goal is to create a rather realistic game. Thanks for reading.

• Where do you use your height parameter inside your function? Jan 29, 2020 at 19:24
• Wait a second... thanks. I will try adding it :D Jan 29, 2020 at 19:25
• This is my new function: double t = Math.sqrt(2 * GRAVITY * height); It outputs something which looks similar to the value of the website (85.20211494220669) but it itsn't correct. (8.69) Jan 29, 2020 at 19:28
• ...why are you multiplying by gravity? Higher gravity should decrease your fall time, not increase it. How did you derive this formula? Jan 29, 2020 at 19:34

I have found a very simple solution to my problem. This is my code: double t = Math.sqrt(2 * height / GRAVITY); Thanks a lot! (ᴵᵐ ᵃⁿ ᶦᵈᶦᵒᵗ)