androidperformanceunity-game-enginebox2dbox2d-iphone

Box2D multiple fixtures vs multiple bodies


I have a game that uses Box2D. Sort of a platformer. It has multiple shapes, forming different objects of a stage. At this point I'm making those by creating separate body for each object (it is more convenient in my implementation of the engine), but it totally can be done with only one body having multiple fixtures attached to it.

Is there a reason for me to go extra mile and make my entire stages with only one body and multiple fixtures or the performance boost will be irrelevant?

P.S.(I'm making a mobile game. iOS and Android)


Solution

  • Making an entire stage with one body would be a horrible idea.

    Consider:

    Even if you have actual, measured and identified problem with the number of bodies (and not the number of fixtures), I would advise against going in this direction.

    Note that, in general, having multiple fixtures in one body is normal, and even necessary in a lot of cases. Just don't do it to your entire stage.