# Custom Physics Glitch

// Blend file
// ~650 kb

Occasionally, when coming in contact with the ground, the player object will hover above the ground plane and start bouncing on it’s own. It has something to do with my " own.worldPosition.z += own[“jetpack_force”] - own[“gravity”] " on line 87. When printing both properties, both are 0 when the player object starts to hover, it’s only when the ground plane is out of range of the player’s ray sensor (which is used to detect the ground; setting both properties of gravity and jetpack force to: 0) that the player falls again, and starts to bounce.

Thank you,
TomCat

Not sure if this is your problem, but your equation does not work.

Do you know dimensional analysis? Pretty much you write everything in base units (time, mass, distance, charge, and temperature), and then check that an equation cancels down to 1=1. It is one way to check an equation is not physically impossible

You have the equation:
location = force - gravity

So we have:
D = MD/t - D/(t*t)
(D = Distance, M = mass, T = time)

Note that I’ve assumed gravity is the acceleration due to gravity.

As you can see, this equation does not simplify down to 1=1, and thus your original equation is not dimensionally consistent, meaning that there is no way for it to produce realistic results.

What I want to know is why you’re even directly changing the position. I’d rather be adding a force with applyForce(force, local). And using built in gravity. When you want to hover, simply add a force to counter gravity.

So how to fix it? Well, I’m not sure exactly what you are trying to do, but a start would be:

``````
GRAVTIY = mathutils.Vector([0,0,-9.81])
force_vec = own['jetpack_force'] + GRAVITY*own.mass
own.applyForce(force_vec, False)
``````