Negating gravity with addForce

I wrote a controller which does nothing but calls addForce on a dynamic node with vector (0, 9.8, 0). So I assumed that as this controller ran, the object would not be affected by gravity. I'm wrong. :x

With gravity disabled, if I add multiple forces then the force vector shown in debug just changes direction to reflect the sum of them all. Yet if I enable gravity, it displays TWO force vectors. Even if the force up is greater than gravity, the object still accelerates downward (granted a little slower). Can't figure it out.

Gravity is shown as a separate arrow, that’s correct (as the physics simulation models it separately as well).

Did you add that force in a physics callback? If no, that’s the problem - you need to apply the force every step. (not just every scenegraph update)

It was late and I my reasoning skills were coming up with all kinds of bad math to explain it. But then I woke up with sanity and I figured it was going to be something like you said. I'll give it a shot when I get home. Thanks Irrisor.

Shouldn't it be 9.8 * mass?

skyuzo said:

Shouldn't it be 9.8 * mass?

Haha, you might be right. I tried all kinds of things. Not entirely sure, will figure out by trial and error. ;)

I've not taken physics yet (next year is my first year in physics) but if I remember correctly gravity is -9.8 mps^2… do you have to take care of the ^2 part?

In physics fun i have added a simple callback which adds force every step.

I called it wind callback, because it has more impact on light objects than on heavy.

As skyuzo  already said, if you multiply the force with the objects mass, it behaves like gravity.

    public void beforeStep(PhysicsSpace space, float time) {
        for (PhysicsNode n: space.getNodes()) {
            if (n instanceof DynamicPhysicsNode) {

Great! Thanks for sharing, saves me some frustration.

Trussell :

gravity is an acceleration, not a force.

to get a force you need to multiply the acceleration and the mass of the object.

gravity is 9.81 m/s

Physics callback with addForce(9.8 * mass) works like a charm. Thanks guys.