DistanceJoint2D vs HingeJoint2D

When using a HingeJoint2D, the connected rigid body rotates appropriately compared to DistanceJoint2D which doesn’t rotate at all. Is there a way to make DistanceJoint2D behave the same way, without having to manually rotate the object myself? The connected anchor position is centered to the sprite in each case.

Perhaps offset the connection point to be “higher up” on the sprite? This would allow centripetal force to swing the extra mass of the bottom further from the center of rotation.

I tried that too, and it almost works, depending on the exact position of the offset. But it seems to be unpredictable and will occasionally rotate sporadically.

Immediate response… connected it as close to the edge as possible for maximum centripetal effect. However, when the swing changes velocity, this setup also causes the square to rotate around the connection point.

Hmmm, well, why don’t you want to rotate it yourself? Mind you, there’s angularVelocity for manual rotation needs with physics objects.

You’re either going to be manipulating the square somehow via code, or finagling some monstrosity of physics together when you could have just used a hinge joint.

Maybe explaining your situation more will help us understand what direction the solution lies in.
Honestly, the hinge joint is the way to go here without any further knowledge of why you’re not using it.

Only one reason I’m not using hinge joint: I want to maintain a constant distance between the anchor point and the sprite. But yeah, I guess the only real solution here to update the rotation manually.

Hmmmm… Fixed Joint?

Well, I want it to behave similar to pendulum so that it can swing, etc. I suppose it’s possible to use fixed joint for that, but then the pendulum motion/rotation has to be programmed manually (but at that point, it just feels like a hack around the physics system). It’s actually surprising there isn’t some sort of hybrid distance/hinge joint option available that combines the features of both.

Edit (further clarification): If you imagine something like an iron rod attached to the center of a wood block and you want the rod to be able to swing like a pendulum due to gravity…it doesn’t seem like there is any joint type that would make sense in that scenario without combining multiple joints or hacking something together.

If you only used a fixed joint to join the square and the pendulum arm, it shouldn’t prevent them from using physics. Fixed Joint will only lock an object in place in the world if you don’t supply it with a connected body. Otherwise it’s just a rigid joint connecting the two bodies.