# Box2D joints: Revolute Joint

After introducing Distance Joints, it’s time to learn something about Revolute Joints.

A Revolute Joint attaches two objects by “pinning” them together at an anchor point which they may revolve around.

The most interesting thing, that I will cover in another post, is the capibility of making motors out of Revolute Joints. Yes… motors… engines… easy to do and ecologic since they don’t need fuel, just some code.

But at the moment let’s see the basic Revolute Joint.

Here it is:

Now let’s see how to make this possible:

Line 16: Declaration of `the_rev_joint` variable, a `b2RevoluteJointDef` type

Lines 40-46: Creating a circle in the middle of the stage that will act as a pivot point. In most examples around the web you will find pivot points as tiny, almost invisible boxes. I am making a big one because I think it will be easier to skin it once I will need to do it. Notice at line 41 that the object is static because it has `density` at `zero`.

Lines 48-56: Creation of the box that will be tied to the joint. You can virtually place it anywhere, but for an interesting result, it should be in a position where the joint can act as a fulcrum.

Line 57: Initializing the joint: I am passing the joint pivot, the body tied to the joint and the point of intersection. You can see the `(8.5,6.5)` is the same as pivot’s origin (line 43).

Line 58: Adding the joint to the world.

And that’s it. Believe me, Box2D is very easy once you know the basics.

• PLEASE make the colours a bit darker, I could hardly see the last few box2d tutorials you’ve made. It looks pretty cool but I can’t really tell D:

• “Once you know the basics…”

Where do we learn the basics?

• Nice. Could you do something with Sensors? I have problems to understnad ist :)

• Hey man thanks heaps for you tuts
i am just getting into box2d this is my new work with box2d
http://www.thivy.com

• Manjil Pote

I got it so hard and complicated, very hard to understand.

• Pingback: Basic Box2D rope : Emanuele Feronato()

• Zas

Hello,

how did you make it that the objects rotation slows down after a while?

http://www.box2d.org/forum/viewtopic.php?f=4&t=4264&p=20404

• Emanuele, it would be nice to see how to implement a rubber band with box2d

• God bless you. i looked for this tutorial like my life depended on it. thanks.