# Setting a Box2D Bodies Center?

How do I set the center of a fixture/body consisting of multiple shapes (triangles)?

-
Thanks for working on your accept rate! OK, so what have you tried so far? Also it seems by your image that the first is more centered than the second. What are you trying to accomplish? – Byte56 Jun 13 '12 at 15:04
Does Box2D run in Flash? If not, why is this tagged actionscript-3? – Wackidev Jun 13 '12 at 15:32
The point of this is I'm trying to set where the center of the body is as you can see in the bottom it's in the correct place where the wheels would be by giving the it vertices where the origin (0, 0) is towards the front of the car where the steering wheels would be. However when I triangulate this shape and attach the triangles to the fixture, the center of the body is moved to it's center. Where means when I try and rotate the car it looks odd. @Wackidev, Yes it has been ported to Flash (box2dflash.org) – SyntheCypher Jun 13 '12 at 18:33
@synth Wow; I didn't know that. It's been a long time since I used Box2D, but it would seem that "center" is an immutable point. Can you move the center of a circle without moving the circle itself? It would break the circle's very definition. This is a more complicated shape, but I think the same principle applies. Maybe you could keep an offset vector from the "real" center and perform your rotations around the offset position. – Wackidev Jun 13 '12 at 19:54
So, it's correctly finding the center, and you want to change that to off-center? "the center of the body is moved to its center" Isn't that expected? Can't you just define an offset from true center to where you want your center to be? – Byte56 Jun 13 '12 at 21:22
show 1 more comment

``````bodyDef.position.Set(0.0f, 2.0f);   // the body's origin position.