How to create joints with the mouse?

Hey there. 🙂

I'm pretty new to box2d and I wonder, how I could create a distance joint from one object to the
current point of a object, the player clicks on?
Box2d bodies have functions
Code:
b2Vec2 GetWorldPoint(b2Vec2 localPoint)
and
Code:
b2Vec2 GetLocalPoint(b2Vec2 worldPoint)
.
You can use the second one to determine the coordinates of your mouse in the body's local coordinates. (Use stage.mouseX and stage.mouseY to get the mouse coordinates).

Then you can use these local coordinates in your call to b2DistanceJointDef.Initialize(), that will attach the Joint at the point where your mouse is.
I'll try that, thanks. ^^

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