How to figure out PPM or Pixel Per Meter on Box2D?

118 views Asked by At

The unitScale on my tiled map renderer is 1/16f.

My orthographic camera has the following dimensions: (16f,9f).

Does that mean that my pixel per meter is 16? I'm drawing MapObjectPolygons from my object layer but they are not scaled down like my map, should I divide their proportions by the Pixel Per Meter?

Thanks, I've been reading dozens of articles and questions on the internet but I don't understand this concept still.

1

There are 1 answers

0
londonBadger On

"Does that mean that my pixel per meter is 16?" No take a step back because your Orthographic camera is set up wrongly. Unlike the Perspective camera, it needs the absolute viewport size (e.g. the screen) not a ratio. So you need to set according to the screenWidth and screenHeight.

(From the below link)

float w = Gdx.graphics.getWidth();
float h = Gdx.graphics.getHeight();
camera = new OrthographicCamera();
camera.setToOrtho(false,w,h);

Have a look here https://gamefromscratch.com/libgdx-tutorial-11-tiled-maps-part-2-adding-a-sprite-and-dealing-with-layers/