Rope Bridges

Topics: Developer Forum
Jun 24, 2010 at 11:07 AM

  Hi Guys,

 Been using farseer for three weeks and this is the first major problem, so I'm doing well!

 My problem is that I wish to create a rope bridge, but I've struggled for a day and a bit now and I'm getting nowhere fast.

 First picture shows the bridge, the second shows all the geometry.

 While it looks like I have a bridge, the bridge constantly bounces and when it breaks (like it is meant to) it fires logs to all four corners of the universe.

 My problem is that the bridge constantly bounces if I make it myself (as a collection of bodies from point A to B). I'm not sure what the best joint to use is, I've used revolute, springs and a few others in desperate attempts to make it work.

 Originally I tried using the path factory, but that gave me too many bodies and things got crushed, or gave me gaps between the logs where the player could fall through.


Either the bridge should be very tight with a small dip, or should be quite rigid and anchored at either side (the first and last log). Any idea how I can achieve this?


While I'm at it, as you can probably see, the player is using a rectangle for their geometry and I'm updating the position. I tried using the motor revolute joint but kept having the same problem of sliding. I'm fairly sure I implemented it correctly; I was just wondering what figures other people used to get it working properly. It should be very "Mario" style, instant stop, instant start, but still able to be thrown about by the physics. Linear drag coefficient? Friction? I've already had to turn the restitution down to 0 or else the character constantly flickers because of a pixel or two of bouncing.

 Any help on either of these matters would be appreciated and I'll be happy to provide any information you may need to help solve my problems. :)




Jun 24, 2010 at 10:49 PM
Edited Jun 24, 2010 at 11:04 PM

Firstly, make sure that the collision categories are correct and the rope Bodies ignore each other. Also try turning up the iterations in the physics engine, that can really help when you have a lot of joints together.

With revolute joints you should make sure that one of the anchor points is (0, 0), and the other is (spacing, 0), or whatever axis you use. If one of the anchors is not (0, 0) then the bodies wont be able to rotate even a little bit, and with gravity always pulling them down that might cause the shaking.

With my character, using the box-and-wheel technique, I give the wheel a way-high friction of 20, or even higher. This makes sure he stops dead when I want, and he doesn't slide down slopes any more than other objects. When the player stops, or "brakes", I found it was better to use an angle joint than to set the motor speed to 0, and the motor joint still moves a little and can make sliding worse on slopes.

If you are going to a single shape for your player, I would recommend a rounded rectangle or capsule. And I would definitely NOT recommend updating the position directly if you still want the player to be affected by the physics!

The thing with Mario is that he doesn't act physically-realistically, so if you want a character affected by the physics engine you should make him behave like he is affected by the physics, and then just tone it down a lot until it feels as close as possible, just with a realistic touch!

Jun 25, 2010 at 7:52 AM
Edited Jun 25, 2010 at 2:17 PM

Thanks for the reply Robert.

I managed to get a semi sensible bridge working using a mix of fixed angle joints and revolute joints. Basically, the fixed angle joint is used to stop the logs rotating and dropping in the middle. With a very small breakpoint however they break after the bridge is broken allow rotation as you would expect. I'm trying the collision catagories now to see if that'll fix the jittering problem. I may have to write method so that the logs collide after their joints have broken and they become seperate, but that should be as easy as changing their collision catagory again.


Here's a video of a playtest of my game (it's not me playing, it's my team leader, so he monkeys about a bit before playing with the bridge). You can see the bridge working quite well. I've not changed the character into a ball and box yet though.

The collision catagories made no difference, because the logs are roughly 22 pixels in radius and I make the geometries at around 10 it means there's a good 4 pixel gap between then so they don't collide much at all.

I plan to use them later for one way platforms though.


The next thing I'm trying to do is a sort of earth quake effect. I suppose instead of moving the ground geometry I could apply impulses to all objects and the static ones will likely ignore it, the non-static ones should shake.