Make physics joints connect to somewhere other than center of an object?

Hopefully the title makes some sense.

The easiest way for me to describe the problem was to make this image:

pLc3eBl.jpg

So as the image suggests, I want the ring to be joined at a custom part of it’s physics body, not just in the center. When I put the anchor positions into the pivot joint, it still affixes the joint to the center of the ring.

Can anyone think of a good solution for this?

That should definitely be possible.  Can you show a snippet of your code where you create the objects and the pivot joint?  That way we can figure out why it’s not working.

One thing to note: when you create an off-center pivot joint, the hybrid and debug draw modes show lines emanating from the center of each object to the pivot joint.  I wanted to mention that in case it’s the source of any confusion.

  • Andrew

the hybrid and debug draw modes show lines emanating from the center of each object to the pivot joint

Ah well that’s probably all it is then.

For the record though, my code is simply this:

ringPivot = physics.newJoint( "pivot", ring, pins, pin.x, pin.y - pin.height \* 0.5) 

So it should work as I explained, maybe the hybrid lines are what threw me.

Yeah, that looks fine to me.  It should be easy to test too: just apply a force to one of the objects, or make it touchable, and see whether the joint is where you want it to be.

  • Andrew

That should definitely be possible.  Can you show a snippet of your code where you create the objects and the pivot joint?  That way we can figure out why it’s not working.

One thing to note: when you create an off-center pivot joint, the hybrid and debug draw modes show lines emanating from the center of each object to the pivot joint.  I wanted to mention that in case it’s the source of any confusion.

  • Andrew

the hybrid and debug draw modes show lines emanating from the center of each object to the pivot joint

Ah well that’s probably all it is then.

For the record though, my code is simply this:

ringPivot = physics.newJoint( "pivot", ring, pins, pin.x, pin.y - pin.height \* 0.5) 

So it should work as I explained, maybe the hybrid lines are what threw me.

Yeah, that looks fine to me.  It should be easy to test too: just apply a force to one of the objects, or make it touchable, and see whether the joint is where you want it to be.

  • Andrew