0 votes

I've been trying to figure out a good solution to this conundrum for weeks now, so it's time to ask a question.

I have a simulation where the player can pick up a RigidBody2D and fling it across the screen. I have found that I get the most realistic flinging simulation when I use a nested structure of rigid bodies and a pin joint.

RigidBody2D Object
-- Pickable "Handle" RigidBody2D
-- PinJoint2D

What happens is that I pause the simulation on the "handle",and have it follow my mouse position. The parent body attached with the pin joint, having never paused its physics simulation, is free to bash into other stuff and react "realistically" rather than simply going inert.

I would like to change the pivot point dynamically by changing the position of the pin joint. Imagine picking up your smartphone from the table by the corner: gravity should make it settle down around the center of rotation where you're grabbing it.

However, when I do this, the parent body freaks the heck out. The simulation goes wild.

I'm almost to the point in my experiments where I'm going to clone the scene with the new center of rotation and re-instantiate it into the parent scene, but something tells me that will still go wonky with the physics.

So, those of you who understand the Godot physics simulation better than me how would you go about dynamically updating the position of a pin joint to change the center of rotation between objects without destroying the simulation?

in Engine by (18 points)

Please log in or register to answer this question.

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.