Page 1 of 1

Keeping object hovering/floating mid-air

Posted: Sat Apr 19, 2014 7:09 pm
by AAverin
Hey.
So, I've seen a few topic about that around already, but still can't seem to get it right.
How one would keep an object floating mid-air on some height?

I have a very light object of 0.5g
Gravity is set to 9.801
What kind of force should I apply to make that light object floating on the height of 3-5cm?

I have tried using
applyCentralImpulse for (0f, MASS*G*FLOAT_FACTOR*delta) where delta is time between frames, playing with FLOAT_FACTOR values, but objects keep flying up to the sky and don't want to stay on 3-5cm height no matter what.

Re: Keeping object hovering/floating mid-air

Posted: Tue Apr 22, 2014 1:54 pm
by xexuxjy
One way to do it would be to set the BT_DISABLE_WORLD_GRAVITY flag on your rigid body before you add it to the world. That would prevent normal gravity being applied.

Re: Keeping object hovering/floating mid-air

Posted: Tue Apr 22, 2014 1:56 pm
by AAverin
Thanks for reply.
For now I used rigitBody.setGravity() to a custom, much lower, value then world gravity and apply center force/impulse depending on the current state - fly up, hover, fly down.
That somewhat looks fine but I can't make it smooth enough.