b2PrismaticJointDef explained

Hi, I am trying to learn how to use Box2D from the Ray Wenderlich tutorial site and do not understand the block of code below. I have checked the Box2D manual as well but still do not understand...

I understand that this code locks the paddle along the x plane and not along the y, but I dont get what each line is actually doing

b2Vec2 worldAxis(1.0f, 0.0f); I know it is setting x to 1, but what is the significance?

jointDef.collideConnected = true; I get this, allow collision?

jointDef.Initialize(_paddleBody, _groundBody, _paddleBody->GetWorldCenter(), worldAxis); I dont get the relation to worldcenter and worldaxis?


Code:
b2PrismaticJointDef jointDef;
b2Vec2 worldAxis(1.0f, 0.0f);
jointDef.collideConnected = true;
jointDef.Initialize(_paddleBody, _groundBody,
  _paddleBody->GetWorldCenter(), worldAxis);
_world->CreateJoint(&jointDef);


Thanks
b2Vec2 worldAxis(1.0f,0.0f); sets the direction of the axis (it's a (mathematical) vector). Doing (0.0f, 1.0f) instead would set the direction in the y-direction (thus lock in the y-direction).

jointDef.collideConnected = true; will allow the two connected bodies to collide with each other.

jointDef.Initialize(_paddleBody, _groundBody, _paddleBody->GetWorldCenter(), worldAxis);
worldCenter part specifies the actual point to put the joint, and worldAxis specifies the axis of the distance joint (in this case, the x-axis).
thanks 😉

Original thread: https://box2d.org/forum/viewtopic.php?t=8430