Keeping object hovering/floating mid-air

Post Reply
AAverin
Posts: 9
Joined: Tue Apr 15, 2014 4:49 am

Keeping object hovering/floating mid-air

Post 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.
xexuxjy
Posts: 225
Joined: Wed Jan 07, 2009 11:43 am
Location: London

Re: Keeping object hovering/floating mid-air

Post 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.
AAverin
Posts: 9
Joined: Tue Apr 15, 2014 4:49 am

Re: Keeping object hovering/floating mid-air

Post 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.
Post Reply