Pulling one object to another

Post Reply
User avatar
chaosavy
Posts: 29
Joined: Wed Nov 11, 2009 9:09 pm

Pulling one object to another

Post by chaosavy »

I'm trying to create a "cargo hook" a sort of a line that one object (a space station or a ship) uses to pull another object (a cargo pod, or another ship)

What's a sensible way of doing this?

I've tried constraints, did some experiments, but i'm not even sure I'm using the right one.
I experimented with the 6 degree of freedom constraint, enabled motors, etc, this gives me a pull, but often not in the correct direction, and it seems to be affected by the pulling ship's orientation, which is baffling me.

Summary:
Are constraints the way to go to achieve a pull effect? Is the 6 degree of freedom constaint the one to use?

thanks for any help
User avatar
chaosavy
Posts: 29
Joined: Wed Nov 11, 2009 9:09 pm

Re: Pulling one object to another

Post by chaosavy »

This post is something closer to what I'm looking for: http://bulletphysics.org/Bullet/phpBB3/ ... int#p17937

It shows a distance constraint, I changed it a bit to add a ->setDistance(float newDistance) if the newDistance is smaller than the old then it will use the new distance meaning that the objects can get closer.

Now I need to figure out how to do the pulling force.

If object a and object b

if object a is larger pull object b to it, if object b is larger pull object a to it

but with actual physics :)
User avatar
chaosavy
Posts: 29
Joined: Wed Nov 11, 2009 9:09 pm

Re: Pulling one object to another

Post by chaosavy »

The set distance thing to get the distance between the two objects to shrink but not expand worked in debug mode but not release :(

dammit, it tricked me into thinking that I found a loop hole, debug mode worked since the physics step was slower thus less precise :(

Funny thing I discovered while playing around is that I can sort of create a motor by doing this:

Code: Select all

      info->m_constraintError[0] = 5; // Positive to get closer, negative to get further apart
Although the pull/push force is constant and not dependent on the entities, this may work in some way in my project as a tractor beam/repulsor ray.
User avatar
dphil
Posts: 237
Joined: Tue Jun 29, 2010 10:27 pm
Contact:

Re: Pulling one object to another

Post by dphil »

One option besides constraints would be a soft body chain. There is at least one example in the bullet demos of this, where a large block is swinging from an anchored point, connected by one or two chains of soft body nodes connected by links. The effect is fairly nice. You could also change the link resting length to retract/extend the chains, however this feature is not yet officially implemented (though you could do it manually with a little work). But, there is some code posted on the issue tracker that does this. See: http://code.google.com/p/bullet/issues/detail?id=470, which I integrated into issue 503, which has some additional soft body fixes.
User avatar
chaosavy
Posts: 29
Joined: Wed Nov 11, 2009 9:09 pm

Re: Pulling one object to another

Post by chaosavy »

thanks! I'll look into that, a soft body would show a neat visual effect.
Post Reply