Position of body when two shapes using it

Official forum for the Chipmunk2D Physics Library.
Post Reply
sumitkum
Posts: 10
Joined: Thu Dec 30, 2010 4:51 pm
Contact:

Position of body when two shapes using it

Post by sumitkum »

If two shapes are using a same body, then how will we set the position of the body

body->p = shape1.position;
or

body->p = shape2.position;

How should I handle it
User avatar
slembcke
Site Admin
Posts: 4166
Joined: Tue Aug 14, 2007 7:13 pm
Contact:

Re: Position of body when two shapes using it

Post by slembcke »

Shapes are always positioned relative to bodies. When the body moves, so will the shapes.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
sumitkum
Posts: 10
Joined: Thu Dec 30, 2010 4:51 pm
Contact:

Re: Position of body when two shapes using it

Post by sumitkum »

Yes, shapes will be updated according to the position of body. But, Don't we have to give initial position of body.
User avatar
slembcke
Site Admin
Posts: 4166
Joined: Tue Aug 14, 2007 7:13 pm
Contact:

Re: Position of body when two shapes using it

Post by slembcke »

The position of the body is the position of it's center of gravity. The shapes move and rotate around that.

So when you set the position of the body initially, you are setting it's center of gravity. The shapes attached are always relative to that.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
sumitkum
Posts: 10
Joined: Thu Dec 30, 2010 4:51 pm
Contact:

Re: Position of body when two shapes using it

Post by sumitkum »

I got it, Thanks for your help
Post Reply

Who is online

Users browsing this forum: No registered users and 13 guests