This project has moved and is read-only. For the latest updates, please go here.

Make a surface sticky?

Topics: User Forum
May 20, 2011 at 2:00 AM

Hi all,

First of all, Farseer is a fantastic library. I'm a total noob, but I'm really excited by the possibilities. Thanks to everyone who contributes.

So, my question is this:

Is it possible to make an object/surface "sticky" using some combination of settings? I've been playing around a bit with Restitution and Friction, and those settings don't seem to be what I'm looking for. A few examples to illustrate what I'm talking about:

  • Breakout-type game, where the ball sticks to the paddle in certain circumstances.
  • Guy in velcro suit jumps against velcro wall ("velcro jumping") and sticks to the wall.

Basically I'd like to figure out how to make certain surfaces behave like they're covered with glue/velcro. Is this possible?


May 20, 2011 at 7:47 AM

You can subscribe to a Fixture's OnCollision/OnSeparation events to do something like this. For your examples you will probably need to build some joints to hold the body in place, but you might start by simply affecting the velocity of the other Fixture's body and going from there.

May 20, 2011 at 4:30 PM

As shivajs suggests, you should check the collision, and whent you detect it, create a joint (probably a weldjoint should make it for what you are trying to do). When the joint is no longer needed, you just remove it from the world.