I have a character positioned at (0, 0, 0), and I have a position above the character I want to move them to, let’s say this position changes depending on the circumstance.
Now let’s also say I have a constant force that I apply to the character in form of a BodyVelocity and they go up at a constant rate.
How can I find the time it’s going to take for the character to reach the position above them?
Well, I personally wouldn’t use a body velocity, given that after removing the body velocity there may still be some momentum left over. For this situation, I would use TweenService because it’s more reliable than using a body mover.
Speed = Distance / Time, which means that Time = Distance/Speed.
You can calculate the distance through the means of using .Magnitude, and Speed is obtained from BodyVelocity.Velocity.Magnitude.
So in theory, Time = (distance of two parts) / BodyVelocity.Velocity.Magnitude
But like I said before using TweenService can give more reliable results (still uses Time = distance/speed)
You could use a loop to find if the character’s position matches the desired end position.
For constant force, it really depends on what you want to achieve; I’d personally use TweenService and CFraming to find your calculations easier, but if you’re looking for different results, I’d use body forces to emulate real-time physics.
You can Humanoid | Roblox Creator Documentation to calculate the horizontal speed. Because speed is calculated by distance over time
s = d⁄t
we can rewrite the equation for time. After all, we already know the distance to the point and the speed of the player. So, rewriting it we get:
t = d⁄s