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

Tractor beamishness

Topics: Developer Forum
Jan 18, 2013 at 12:04 PM


First off, I've been using farseer to prototype my new project and I must say it's performing above all expectations! Thanks for a great product!

That said, here's my question!

I want to create a effect of an object being sucked into another object. Think of a stretched rubber band holding a small object and then you suddenly release that object. I should accelerate into the other object (the ship). The ship could be moving also. Once Close to the ship it will just disappear. (when distance < x) so there will be no collision.

My question is: What is the best way to create this effect? What joint type to use?



Jan 19, 2013 at 3:14 AM
Edited Jan 19, 2013 at 3:16 AM

I am kinda new to Box2D but I think you could just use apply impulse to move one object towards another and remove it when its a certain distance from the object, or simply not render the object, and to make them not collide you can modify the body group when creating the body.

for checking distance use this math

distance = sqrt((x2 - x1)^2 + (y2 - y1)^2)

Jan 19, 2013 at 10:21 AM

Hi! Thanks for the reply. Currently I'm using a DistanceJoint, which gives a cool effect when the smaller object is close to the ship. Looks like it's being dragged along for a while. For distance I simply use (v1-v2).Length where vx is a Vector2. I'll try to create something with your suggestion.