Soft ceiling game physics

49 Views Asked by At

I'm making a game that has physics. For now, I have a implemented drag and thrust (upwards acceleration):

$ a_{t+1} = a_{th} (1 - (v_t / v_T)^ 2) $ (acceleration)

$ v_{t+1} = v_t + \Delta t \space a_{t+1} $ (velocity)

$ p_{t+1} = p_t + \Delta t \space v_{t+1} $ (position)

It works well (for example, $ v_t $ will converge to $ v_T $ over time).

However, now I want to add a "soft ceiling". When the distance is large, the physics works as above. But when distance becomes smaller, a repulsive force takes over such that $ p_t $ never reaches above the ceiling.

Preferably this works for relatively high values of $ \Delta t $ and doesn't produce values of $ v_t $ higher than $ v_T $, because then the drag seems to becomes too large.