Box2D magic body connection

General discussion about Box2D tutorials
Post Reply
Posts: 1
Joined: Thu May 10, 2018 7:13 am

Box2D magic body connection

Post by hardcoremore » Thu May 10, 2018 7:20 am


Does anybody have idea how yo model this platform character with Box2D.

This video shows exactly what I would like to implement for my game platform character:

But I really do not understand how it is achieved. There are two things that I do not understand:

1) How are circle body and box body connected so that circle can rotate freely while box is “attached” to it. I know I can add revolute joint to the circle but how to connect box to it. If I connect it with weld joint than box will rotate as well. If I disable rotation to the box and connect them with weld joint then nothing will rotate. If I connect them with distance joint then box will rotate around circle body.

2) How are bullets implemented in this video? Are bullets kinematic or dynamic bodies? If bullets are kinematic then how do they collide with static bodies? If bullets are dynamic then how do they go strait without gravity affecting them.

Many thanks,


Site Admin
Posts: 854
Joined: Sat Dec 22, 2012 7:20 pm

Re: Box2D magic body connection

Post by iforce2d » Sun May 13, 2018 4:11 am

Looks like a simple revolute joint.

The box is set to be a fixed rotation body.
bodyDef.fixedRotation = true;

The bullets are probably dynamic bodies with gravity scale of zero.
bodyDef.gravityScale = 0;

I think maybe you just need to read the Box2D manual before going any further :)

Post Reply