Restrict b2MouseJoint movement to x axis without effecting gravity

I have set up an object that falls from the top of the screen using box2d gravity. I am now implementing the ability to move the object using a b2MouseJoint as set out in the following article.

My question is how can i just effect the x axis movement with the mousejoint and leave gravity to take care of the y axis.

I have tried using the code in the article to limit the movement but that just stops the object from falling at all.

Any help would be great.

Thanks

Upvotes: 0

Views: 126

Answers (1)

godel9
godel9

Reputation: 7390

Have you tried using a b2LineJoint instead? That allows you to constrain a body along a single axis (in your case, you'd want it to be constrained along a vertical line).

Upvotes: 1

Related Questions