29
\$\begingroup\$

I'm starting to learn Unity for 2D development.

So, I am importing several sprites into the game, and I couldn't help but notice that there is a "pixels to units" property, by default on 100. I normally set it to 1. Is there a reason why I would need to have this value different than 1? Or, more generally, is there a reason to have multiple sprites with different

\$\endgroup\$

3 Answers 3

29
\$\begingroup\$

100 pixels per unit would mean a sprite that's 100 pixels would equal 1 unit in the scene. It's simply a scale to say how many pixels equal one unit. This can affect things like physics. A lower pixels to units setting would require more force to move one pixel than a higher pixels to units setting.

Yes, there may be times where you'll want to manipulate the pixels per unit. If you have a tile sheet of 16x16 tiles, you may want to consider setting the pixels per unit to 16 so that you can easily snap tiles together in a scene, for example.

\$\endgroup\$
0
13
\$\begingroup\$

Answering the question in your title, units in Unity are arbitrary. It's just a number; the most common interpretation is that 1 unit means 1 meter, but that's just the most commonly agreed upon value. You could decide 1 unit = 1 foot, or 1 unit = 1 inch, etc.

As for why you would use the default setting of 100 pixels, it's because the physics system doesn't like values that are too large. If you set 1 unit = 1 pixel, then the physics system would be moving objects hundreds of units per frame, and the physics calculations tend to break down in that situation. By setting 1 unit = 100 pixels, then physics will be moving objects more like a couple units per frame.

\$\endgroup\$
0
\$\begingroup\$

The time you would have to change the Cell Sizes or Scale depends on the size of your tiles. So let's say that you have tiles that are smaller than the usual 100 PPU (Pixels per unit) that you need to resize your Tilemap's Grid cells. To resize your Tilemap's grid cell sizes, go to Grid in the Hierarchy > Grid in the Inspector > Cell size. Divide your tile pixel size by 100. For example, if I have 16x16 pixel sized tiles, the Cell sizes in the X and Y columns will be 0.16. Hope this helps.

\$\endgroup\$
3
  • \$\begingroup\$ Please post in the "Your Answer" box only when you want to share a new solution to the problem. Answer posts are not for asking new questions. Instead, you should use the search box to look for past Q&A that may answer your question, like "What sprite size should I use?", "What PPU should I choose for assets aimed for different resolution?", "Understanding pixel art in Unity" or click "Ask Question" to ask your own if you still need help. \$\endgroup\$
    – DMGregory
    Dec 14, 2021 at 0:48
  • \$\begingroup\$ Re: your edit, I would not recommend a PPU of 0.16 when making a tile-based game with 16-pixel wide tiles. A much better option is to use a PPU of 16. That way each 16-pixel wide tile maps to 1.0 units of world space, a very clean and intuitive mapping. A PPU of 8 makes sense too, where each tile spans 2x2 world units, making both tile corners and tile centers sit on integer coordinates. \$\endgroup\$
    – DMGregory
    Dec 14, 2021 at 0:50
  • \$\begingroup\$ DMGregory: Okay, thanks for letting me know and for clarifying! However, the only thing that sucks is that when I did the PPU of 16 earlier, I have to resize my player character, along with like 20 other animations of the character, which would take more time. \$\endgroup\$
    – SQL N3rd
    Dec 14, 2021 at 0:58

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .