Floating stuff

General discussion about Box2D tutorials
Post Reply
kcid42
Posts: 2
Joined: Sun Feb 03, 2013 11:29 am

Floating stuff

Post by kcid42 »

I am making a game with floating stuff. Because other non-floating stuff can stand on the stuff, i do not know the weight of the sum of objects. How can i make the floating stuff come to rest at a constant position, even with gravity and other objects standing on it?

My first idea would be to counter the gravity with an impuls based on the speed of the object, but then you are always a round too late, and the object will swerve around its original origin.
iforce2d
Site Admin
Posts: 861
Joined: Sat Dec 22, 2012 7:20 pm

Re: Floating stuff

Post by iforce2d »

Yes, applying an impulse or force is one way. You would have to check the position every time step to know what impulse to apply, but I don't think being one step behind would be a problem - it would have to be done gradually anyway.

I'm assuming you mean floating like in water, but if you are talking about floating platforms, you might be able to use the motor joint, which was made for that kind of situation.
Post Reply