1
$\begingroup$

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$.

$\endgroup$
1
  • $\begingroup$ something must be wrong, reversing the velocity should work, unless there were other forces acting in addition to gravity? $\endgroup$
    – user65081
    Commented Dec 13, 2019 at 17:24

1 Answer 1

1
$\begingroup$

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$).

$\endgroup$
1
  • $\begingroup$ Thanks a lot! Works like a charm! $\endgroup$
    – Thrindil
    Commented Dec 13, 2019 at 12:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.