b2Buoyancy limited

Hi there, i've been playing with b2Buoyancy a bit trying to make a bucket in my box2d world with water in it controlled by b2Buoyancy.

Is this possible ? cause i cant figure out how to limit buoyancys width to (for example) 200w 100h, and the rest is box2d world.

Thanks
Can you just check the horizontal position of the body and decide whether to apply buoyancy or not?
Hi and thanks for the answer.
Thats an interesting approach. Didnt think of that.
But what if you want to add water to a small portion of the screen.
Like a lake or something. Should have to add it in the whole lvl and check positions.
Really its not possible ?
Flash people have it :p not fair. Hehe
yeah, i am not getting anywhere with this :/

The thing is that all the ContactListeners that i know of check for collisions when 2 things touch.
I've made a sensor to see when an object 'touches' the bouyancy area and i can then do bc->Addbody(BodyA); to make it float on the surface, but when its out of that area, i cant know that cause the listener isnt broadcasting that the objects stopped touching, so i can do bc->RemoveBody(BodyA).

Any ideas ? or hints ? or better ways to limit the width of bouyancy ?

Thanks
Are you using BeginContact to detect when the object touches the buoyancy area? There is also an EndContact you can use to detect when things stop touching.
Yeah i thought i could do something with that, but i never saw anybody touching it, so i thought i shouldnt play with that either, and that i could do everything in my update method instead.
Ok i'll look into it. Thanks 🙂

Original thread: https://box2d.org/forum/viewtopic.php?t=8717