Make a rope with SKPhysics and SKPhysicsJoints for a suspension bridge

Is it possible to make a rope in Sprite Kit with  SKPhysicsJoints? The simple answer: sure! you just have to make a lot of small single SKPhysicsBodies and connect them with SKPhysicsJointPins. As you can see in the little demo video we also added bigger pieces below the rope to simulate a whole suspension bridge. To make a rope with single parts connected with pinned joints you don’t even need so much jointed elements. Just let the sprite overlap a bit the physics body to make it look very real.

We also added an element which breaks the joints chain when the collision of the SKPhysicsBody is true.

So here comes the code. The methods are separated into two parts. First part is the ground of the bridge. It iterates through n given times to create and pin little SKPhysicsBodies. Also the „breaking“ element is made into this loop. And last but not least the left and right anchors are set to tie the whole bridge up. The second method creates the rope elements an add it also to this anchors.

 

One thought on “Make a rope with SKPhysics and SKPhysicsJoints for a suspension bridge

  1. is it possible for you guys to make this one with swift , I am trying to make an Bow with Arrow with this suspension effect, I am searching for clue , this one is the closest one I could find .

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert.

*
*
Website