# making a rope bridge (jME3 and physics)

Added 29 Oct 2013, 3:02 a.m. edited 19 Jun 2023, 3:39 a.m.

I previously alluded to the idea that constrains (joints) could be used to make a bridge. Most of the code should be reasonably familiar to someone who's had some basic experience with jME3, so I won't go into major detail. Setting up the individual planks of the bridge is straight forward, but its worth mentioning that the objects are in array, the index of the array is related to the position of the plank so the joints can be added from left to right in order.

```        for (int i = 0; i < 7; i++) {
parts[i] = geom.clone();
if (i == 0 || i == 6) {
partsPhys[i] = new RigidBodyControl(0);
parts[i].setLocalTranslation(7.5f - 2.5f * i, 0, 0);
} else {
partsPhys[i] = new RigidBodyControl(1);
parts[i].setLocalTranslation(7.5f - 2.5f * i, 2, 0);
}
partsPhys[i].setSleepingThresholds(0.01f, 0.01f);
rootNode.attachChild(parts[i]);
}```
The first and last plank are static (zero mass) which allows the bridge to be anchored. When setting up the joints we have to lock the rotation on the x axis - the direction of the bridge. You could use two chains of joints, however with the "slop" in the joints it looks okay with just a single chain of joints going down the centre of the bridge.
```        Vector3f p1 = new Vector3f(-1.25f, 0, 0);
Vector3f p2 = new Vector3f(1.25f, 0, 0);
for (int i = 0; i < 6; i++) {
joints[i] = new SixDofJoint(partsPhys[i], partsPhys[i + 1], p1, p2, true);