user891123
user891123

Reputation: 391

How to restrict motion to vertical in box2d

I have a box2d body that has a fixture of a ball. It just bounces up and down on top of a rectangular box. Sometimes it will fall off of the box for no apparent reason. I there a way to restrict gravity to only vertical so that I can solve this problem?

Upvotes: 1

Views: 411

Answers (2)

Que
Que

Reputation: 31

Or you could use a prismatic joint. Check out this video.

Upvotes: 1

Andrew
Andrew

Reputation: 24866

Use b2LineJoint to allow your body to move in one direction only

Upvotes: 0

Related Questions