Container to box2d

Hi! I try to make a container for balls in Box2D.
Why the balls fall when I move the mouse fast?

I see that this happens not box2d playground. I have to add joint?

Any suggestion?


containertobox2D.v4p (53.2 kB)

The very short answer is that you are updating the position of the “basket” to a new position that is not next to the “balls”. In other words there is no interpolation between the original position and the next, rather the basket is in contact with the balls and then it is not.

In order for the basket to carry the balls to the new location the basket needs to be moved with box2d physics. You could use createmousejoint-(box2d) to move the basket (remember to also use movemousejoint-(box2d) to update the position of the joint). If you decide to use this method you will need to change the way the basket is created.

What gaz said is the way to go.
I gave it a shot to try it right away and well, it works nice.
Note that the basket is now a dynamic body with a fixed rotation.

containertobox2D_mousejoint.v4p (52.8 kB)

Thanks for the help! is very useful, and opens up many possibilities
sorry for my bad english!