Hi @reyanthonyrenacia,
Joints can be tricky on basic principle, so you’re not alone in the frustration. Can you show a screenshot of what’s happening, with “hybrid” view turned on so I can see the joint?
You’ve probably already seen the docs, but just to clarify: a pivot joint works as if you hammered a nail through two overlapping boards, and then those boards will rotate around that nail like an axle. So, the bodies should be usually be overlapping (although they don’t need to be), and the X/Y of the pivot is somewhere in the overlapped region. This is why there’s only one X/Y pair for the pivot joint, unlike some joints which need two X/Y pair-points to join two bodies.
Try the following sample, which is a greatly simplified pivot joint example. Zoom in on the Simulator to see how the point of the pivot is where you specify.
[lua]
local physics = require(“physics”) ; physics.start() ; physics.setGravity( 0,9.8 ) ; physics.setDrawMode( “hybrid” )
local box1 = display.newRect( 50,50,100,100 ) ; box1:setFillColor(255,255,255,100)
physics.addBody( box1, “static” ) ; box1.isSensor = true
local box2 = display.newRect( 75,110,50,200 ) ; box2:setFillColor(255,255,255,100)
physics.addBody( box2 )
local joint = physics.newJoint( “pivot”, box1, box2, 100, 125 )
box2:applyAngularImpulse( 40 )
[/lua]
Also remember that pivot joints can have restricted ranges of motion. This is why people use them for “rag dolls” and such. Just tell the joint that it can’t move past a certain angle offset from its original position:
[lua]joint.isLimitEnabled = true
joint:setRotationLimits( -5, 15 )[/lua]
Hope this helps,
Brent