how to stop my rotating kinematic body 2d from breaking rigid body 2d through the wall

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By lincolnpepper

I have a rotation widget you can rotate by clicking and holding a little dot and moving it around an origin that will rotate everything under it around the origin. I have a rigid body 2D ball that interacts with the orbiting objects within the rotation widget. But the objects in the rotation widget can break the ball through walls. I’d like to make it so that if the orbiting object is forcing the rigid body ball against a wall then it should stop moving the rotation widget to prevent it from pushing the ball through. How might i do this?

Here’s a video of this happening, since this is difficult to describe through text:

the orbiting objects and the walls are rigid body’s in kinematic mode, and the collision shapes are collision polygons, if that helps at all. I’ll post whatever code of mine that you need.

:bust_in_silhouette: Reply From: GreyMiller

That happens because your ball gets stuck between a static and kinematic bodies (or two kinematic). These types are not affected by any forces or collisions, so in other words an unstoppable force meets an immovable object. Try switching CollisionPolygons’ build mode to solids, this might help a bit pushing the ball out of the wall instead of getting it “swallowed”. However the ball can still be pushed into the wall, so you’ll need to find some workaround not to let the ball be squished between them.
My quick suggestions:
a) switch the orbiting walls mode to rigid mode and control it applying forces
b) use get_contact_count of a ball and if it is greater than one… idk, maybe then use move_and_slide for widgets? (However using it permanently can prevent them affecting the ball at all, but try and see what happens)