# how do I create a moving type of block like in Mario[box2d]

I want to create a block which only moves up and only when hit from below. I am trying out a distance joint and I read it can be used as a spring, is this the correct solution?

the way I have tried it is to create a block, and right underneath it I created a body and created a distance joint between these 2, however I do not see any type of spring physics, the block just falls down and acts like a rope joint.

DistanceJointDef j = new DistanceJointDef();
j.type = JointType.DistanceJoint;
j.frequencyHz = 4f;
j.dampingRatio = .5f;
j.bodyA = body;
j.bodyB = body2;


my joint def.

edit: right now I am just using a pristmastic joint and so far it seems okay.

• What are you trying to create? Do you want one of those movable blocks from the newer games that will move by one block height and stay there? Or are we talking about classic blocks being bumped from below? May 16 '14 at 20:17
• classic, like I am playing mario and I hit 5 blocks and they all get destroyed, maybe one gives me a mushroom. So far I might have found a solution by using a prismatic joint, this way it only moves vertically and by a certain amount. May 16 '14 at 20:39