# Calculate time it takes for an object to fall

I’d like how know how to calculate the time it would take for an object to travel `x` studs while falling. I’m not too sure how roblox’s physics system works, and I couldn’t find any articles on falling speed.

I’ve created a boss fight system, and I need to know how long it will take for an object the boss spawns to hit the player.

1 Like

You could use heartbeat.
https://developer.roblox.com/en-us/api-reference/event/RunService/Heartbeat

That doesn’t really help much - I need to calculate the time it takes for an object at x studs to fall.

``````X = workspace.Gravity / seconds ^ 2
``````

This is how far any object falls in `seconds`.
The devhub says it’s `Gravity/seconds^2` in studs per second.

To find out how long it’ll take for any part to fall X studs, we just have to reverse that (sort of)

``````seconds = math.sqrt(workspace.Gravity / X)
``````

Let me know if it worked for you!

2 Likes

How about use `tick()`
Because maybe it helps how long it falls.
And likely print the tick.

Trying this solution out right now. I’ll tell you if it works or not.

1 Like

Note this equation is only for when the initial velocity is zero. If it isn’t, you can use this equation:

x = v_i * t + 1/2 * a * t^2

You can also get the distance below the object with raycasting.

3 Likes

Hm. This doesn’t seem to be working. Could I have some help?

``````local BeforeFireballTime = math.sqrt(workspace.Gravity / 35)
-- I set a tween's time to the variable above *2
-- and I want a fireball to reach the ground at the same time it finishes
wait(BeforeFireballTime)
local fb = rs:WaitForChild("Fireball"):Clone()
fb.CFrame = obj.CFrame + Vector3.New(0,35,0)

``````

Seems like you’re creating the fireball after waiting the time it takes for it to fall onto the ground. If this isn’t what you wanted, move the code that creates the fireball above the `wait(BeforeFireballTime)`, otherwise I need more info as to what you’re trying to do

1 Like

I set the tween’s time to double the BeforeFireballTime, so it waits a single BeforeFireballTime, then drops the fireball.

Okay, I don’t see anything wrong with the code. In what way is it not working?

The fireball is falling about half a second after the tween completes, and I’m not sure why. I’ll go back into the code real quick and see if there’s any other unnecessary waits.

Could you send the code that tweens the fireball?

Give me a moment. I think I may have accidentally set a variable to the wrong value.

1 Like

This formula does not help, but this one should:

``````local Time = math.sqrt((2 * Distance) / game.Workspace.Gravity)
``````

It’s the real life physics equivalent. I tried it in roblox and it works fine.

yo that’s silly.

I am pretty sure the formula for acceleration is
`s = ut + 1/2at^2 `
s is the distance
u is the initial velocity
t is time and a is acceleration

I literally used my formula for my game. I can assure you that my formula converted onto Roblox works perfectly. You are correct in using that physics formula for applications of free-fall however in the context of Roblox, using that formula is reduntant at best. Using the implemented Roblox methods to simulate free-fall is the better approach. Hence my usage for my formula.