I’m developing a little prototype game using the built in physics in v.3 and am having difficulty understanding how PhysicsFixedJoint should work.
I have a large circular body (‘wheel’) that is fixed in the world with a PhysicsJointPin at its centre and can freely rotate. I want to fix a smaller circular body (‘ball’) to be touching the outside of this body, so that they will become locked together.
This screenshot shows how this looks so far http://i1293.photobucket.com/albums/b589/stevebarnegren/Screen%20Shot%202015-06-08%20at%2012.52.08_zpsljbrijij.png
It sort of works, but as you can see the green dot representing the joint is in a funny position. Sometimes this joint will differ greatly from the position of the ball, causing the physics to go haywire.
I suspect that it is to do with the third argument when constructing the joint (anchor point):
cocos2d::PhysicsJointFixed *joint = cocos2d::PhysicsJointFixed::construct(ball->getPhysicsBody(),
wheel->getPhysicsBody(),
Vec2(wheelPos.x - jointXDist, wheelPos.y - jointYDist));
This places the anchor point at the point where the ball and wheel touch, is that correct? I have double checked the maths by placing drawNodes at that point, but the joint debug dot never shows up at the same position.
Any help would be greatly appreciated!