I'm making a game and need to figure out how long it will take an object to fall to a certain height.
The object has an initial y value (y), an initial vertical velocity (vy), a gravity constant (gravity), and the vertical target distance it is supposed to drop (destination).
I can figure this out using a loop:
int i = 0;
while(y < destination) {
y += vy;
vy += gravity;
i++;
}
return i;
The only problem with this is that I need to do this for several hundred objects and I have to do it every frame.
Is there any way to figure this out using some kind of formula? That way I can speed up my game while still figuring out this problem.
Thanks