# Calculating a free fall vector so its equals to its inverse vector while accounting for gravity

I'm a game developer, and I've been struggling with a kinematics problem in the development process of my current project.

I have some stationary objects that are suddenly affected by gravity after a period of time. Now, after say 2 seconds, I want those objects to 'cancel' their free falling, and return to their starting positions. Currently, I do this by inversing their downward velocity as soon as I want them to move up again. However, they never quite reach their starting position, since they are still affected by that gravitational force. How do I 'reverse calculate' this gravitational force, so that the upward velocity is big enough to move the objects back up at their starting positions while still being affected by gravity? Note that drag doesn't come into play, it's just the gravitational acceleration of $$-9.81m/s^2$$.

• something must be wrong, reversing the velocity should work, unless there were other forces acting in addition to gravity? – Wolphram jonny Dec 13 '19 at 17:24

An easy way to do this is to give them enough kinetic energy to return to their starting position. That is (in your case $$g=9.81$$):
$$\frac{1}{2}v_{\text{up}}^2 = g\Delta z \Rightarrow v_{\text{up}} = \sqrt{2g\Delta z}$$
So, by changing the current object's velocity to the velocity $$v_{\text{up}}$$ above, it should return to its original position ($$z = \Delta z$$, assuming you are currently at $$z = 0$$) exactly.
If you do not know exactly the position of the object, it can be calculated as $$\Delta z = \frac{1}{2}g(\Delta t)^2$$, where $$\Delta t$$ is the time past since the free fall was activated. This can be derived easily by solving the differential equation dictating free fall ($$\ddot{z} = -g \Rightarrow z = -\frac{1}{2}gt^2 + C_1t+ C_2$$ and imposing the initial conditions $$z(0) = \Delta z, \dot{z}(0)=0$$).