0 votes

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.

in Engine by (243 points)

1 Answer

0 votes

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)

by (42 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.