# Setting a Box2D Bodies Center?

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

• Does Box2D run in Flash? If not, why is this tagged actionscript-3? Jun 13, 2012 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) Jun 13, 2012 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. Jun 13, 2012 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?
– House
Jun 13, 2012 at 21:22
• I don't understand why you chose to triangulate these shapes? They are convex and don't have to be triangulated.. just keep them as they are. Aug 13, 2012 at 7:08

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