## How to join two bodies so that they keep a constant distance

Official forum for the Chipmunk2D Physics Library.

### How to join two bodies so that they keep a constant distance

I would like to have two bodies that are joined like this:

Code: Select all
`A||B`

and body B should always be at the same distance from A and shouldn't rotate around a pivot. It should always straight down below A. How would you achieve that with Chipmunk?
tanis

Posts: 1
Joined: Thu Jan 16, 2014 1:52 pm

### Re: How to join two bodies so that they keep a constant dist

A pin joint will maintain constant distance between two bodies. I'd suggest adding one between the centers of each body unless you want B to move up and down as A rotates.

However, this will not guarantee that B will always be below A. For instance, if the forces and velocities of each body do not match then it is likely that they will move out of alignment (although the pin joint will keep their distance constant). I can't think of any combination of existing constraints that is capable of keeping B directly below A. The simplest option would be to make bodies A and B into shapes 1 and 2 of body A (no constraints required since shapes never move relative to their body) and give that body an infinite moment of inertia to prevent torque from rotating it. If it's necessary to keep them as separate bodies then I think you may need to write your own constraint solver (see cpPinJoint.c for an example).
LegoCylon

Posts: 29
Joined: Wed May 09, 2012 12:06 am

### Re: How to join two bodies so that they keep a constant dist

A pin joint will maintain constant distance between two bodies. I'd suggest adding one between the centers of each body unless you want B to move up and down as A rotates.
If you are looking for fast success in certkillerthen join today to 70-412 dumps find complete testking and pass passguide on first try. A person can pick www.hood.edu and University of Hawaii for its easiness.
ranaraza

Posts: 1
Joined: Thu Apr 23, 2015 1:28 am