- Home /
doubt with pixels per unit
Hi. I have a question about pixels per unit (ppu). I understand that means that for each unity unit they fit x pixels (100 by default). Is it recommended to edit the ppu value of each image so that it fits in the game? For example: I have two images of 1920x1080, a dog and a house, can you put a ppu of 64 for the dog and 512 for the house or should you play with the scales of the transform? Thanks.
usually scaling is to be avoided. the uniform scale of 1 is the best you can work with in terms of childing, physics and such. use the PPU settings as they leave this untouched.
It depends on what your graphics should represent. 1 Unity unit should be roughly 1 meter so the physics work right.
So, if i have a big image of a knife i should edit the pixel per units, right?
Answer by pako · Oct 09, 2018 at 08:12 PM
It seems to me that you are looking at the problem the wrong way around.
What you should have in mind is to get a match between the game world and the size of your textures. IMHO it's much more convenient to have a fixed ppu for a particular target resolution.
It's easier to think about this in a 2D game:
e.g. if your target resolution is 1920x1080, then if you set ppu of all your textures at 100, then this means that one screen width represents 19.2 meters and the screen height will be 10.8 meters in the game world.
So, you will need to size your backgrounds accordingly. Also, in the case of the dog and the house: if you want the dog to be 0.5 meters long, and 0.3 meters tall, you can calculate how many pixels you need to make your texture: 0.5 meters corresponds to 0.5 / 19.2 = 2.6% of the screen width, and 0.3 / 10.8 = 2.8% of the screen height. Since you know the world size of 19.2x10.8 meters correspond to resolution is 1920x1080, then 1920 x 2.6% = 50 pixels, and 1080 x 2.8% = 30 pixels. So, your dog texture should be about 50x30 and it will have a good size in the screen relative to other objects. In practice you will make the dog texture slightly larger in order to add some transparency around the boarder, and you'd also need to account for changes to the dog image due to animation. Similarly, you could calculate the pixel size for the house, etc.
Now, if you wanted to target an additional resolution of say, 960x540, and provide smaller textures for that, it would be easy to adjust the texture sizes of all your objects to 0.5 of what they are for 1920x1080. However, in this case, you would need to adjust the ppu to 50, because you'd then get 960 / 50 = 19.2 meters wide and 540 / 50 = 10.8 meters high, i.e. your game world will be the same size as at a higher resolution. So the dog's texture would be 25x15, but still the same size in the game world.
Now, if instead of having uniform ppu per target resolution for all your objects, you changed the ppu per object in the same target resolution, I think it would be quite hard to size your objects (IMHO).
Interesting answer. So i should think the game in the desired resolution and then make the images. In this way, the ppu edition affect all the images in the same time. $$anonymous$$akes sense.