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

Temporarily Joining Two Objects

Topics: Developer Forum
Aug 17, 2008 at 10:45 AM


Is there some easy way to temporarily join two objects? I was trying to use RevoluteJoint and AngleJoint together, but it seems it doesn’t work well for me, once first object is already rotated, joining another one to it forces the second one to rotate, not just stick with it. Any idea?


Aug 17, 2008 at 7:49 PM
Hmmmm, i dont really understand what u want to do?
Aug 18, 2008 at 4:32 PM
I think what he want is placing 2 bodies next to each other and make them behave as one.
Aug 18, 2008 at 7:22 PM

Yes, this is exactly what I want, but how?

Aug 19, 2008 at 11:29 PM
I guess u could add limit joint AND the one that Limits length apart from each other?that way they bosth stay as if they were "Joined By The Hip"
Aug 20, 2008 at 6:41 PM
I use RevoluteJoint and AngleJoint (or CreateAngleLimitJoint), but the problem I encounter is that if the one of the bodies is already roatated the second one rotates by the same angle before they become “joined by the hip”.
Do you know hot to prevent the second object from this rotation?
Sep 30, 2008 at 11:02 PM
Edited Sep 30, 2008 at 11:05 PM

I have to say that I still don’t know how to do this. If you could take a look at picture:

I draw an rectangle at an angle

2.       It drops to the ground and changes its angle according to the ground

3.       I draw another rectangle at it, it should join with the previous one

4.       they join, but the second one changes its angle by the amount from the pic.1

I use RevoluteJoint and AngleJoint, but apparently  I made mistake. If someone can take look at and let me know what am I doing wrong I would be grateful.
Oct 1, 2008 at 2:03 AM
Try setting the TargetAngle of the joint to be the same as the bottom box. 
Oct 1, 2008 at 11:16 AM

my code looks like this, newEntity is newly created object and e is the previous one.


RevoluteJoint rj = JointFactory.Instance.CreateRevoluteJoint(PhysicsSimulator, e.Body, newEntity.Body, a);

AngleJoint aj = JointFactory.Instance.CreateAngleJoint(PhysicsSimulator, e.Body, newEntity.Body);

aj.TargetAngle = e.Body.Rotation;


when I set the target angle it’s even worst, those joined object tends to jumps by themselve...

Oct 1, 2008 at 5:32 PM
Maybe try setting the TargetAngle to 0? Or set the bodies angle to 0 right before creating the AngleJoint? Is there actual collision between the blocks or just a collision event? I haven't had a chance to take a look yet but hopefully I will get some time tonight.
Oct 2, 2008 at 4:40 AM
It might take some fancy programming but I'd try literally combining them into one object.  Basically it would involve removing the original two objects and creating an entirely new object based on the properties of the originals.  This might be something that needs to be added into 2.0.  It's not overly complicated but it would require a lot of work.
Oct 2, 2008 at 12:45 PM
I'm not sure that such a thing belongs in a physics engine. If it's really simple it can be included, but the polygon union algorithms I have seen so far, is kind of complex.

While writing this post, I decided to test it out for myself. I ended up modifying demo2 from the GettingStarted demos from Farseer Physics 2.0 to include polygon union. The interface of the polygon union code is really simple (got the code from here: but it has a buggy implementation.

You can get the code for the demo here:

Enable debug view by pressing F1 to see the outline (vertices) of the union polygon. It uses the local vertices of the 2 rectangles, so it does not take their relative position into account. I used worldvertices in the beginning, but it seems to be bug out the union code.
Oct 2, 2008 at 10:53 PM

Thank you all for your help, I used  PolygonUnion class, that was it!