Best way to emulate hole

Dec 1, 2010 at 2:24 AM

I need to emulate a hole to lock a rolling ball. The hole behavior should be:

  • if moving ball cross the hole with small velocity/applied forces, it should be locked in hole;
  • if forces, applied to the ball, exceed some threshold, ball should be unlocked and continue movement.

What is the best/easy/smart way to do this?

Coordinator
Dec 1, 2010 at 12:49 PM

Is this a top-down type game, like pinball?

If so I would probably just use a Sensor (add a PhysicsObjectBehavior and set IsSensor = true).

Then in you collision event you could check for this sensor and create a joint to hold it in place. You could have the joint be breakable under certain force, or just check the force of any collisions and remove the joint.

Dec 1, 2010 at 1:52 PM
Edited Dec 1, 2010 at 3:52 PM

Not a pinball game at all, just a different kind - don't know how to explain better :) The game goal is to put (and keep) all balls in the holes.  I'm using the accel sensor.

Thanks for suggestion but could you please provide a simple example? I'm novice in a Farseer engine and PhysHelpers... I've already checked your examples and project discussions but can't find any info.

Also, about Sensors usage: it reports a collision of objects "borders" only in the current Helpers implementation. AFAIK (but not 100% sure) the Farseer engine have some additional events. Actually, I should hold the ball if it fill at least 3/4 of the hole. Otherwise it should continue movement, probably with changed direction (to "real world"-like simulation).

Thanks a lot (and special thanks for the Helpers, nice and useful project!)

Jan 2, 2011 at 11:25 AM
Edited Jan 3, 2011 at 9:12 PM

Just out of curiosity, am I the only one who doesn't seemto be able to find "IsSensor" anywhere within the latest PhysicsHelperLibrary?
I could really use this behaviour right now, but I can't find the option in Blend nor programatically in VS using the 4.0 beta

Regards,

Mark Kane

Edit: Okay, found it in the Objects Fixtures, well hiden... ;)

physicsObject.BodyObject.FixtureList[0].IsSensor = true;