22
\$\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\$
18
\$\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 unit 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\$
  • 3
    \$\begingroup\$ A higher pixels to units setting would require more force to move one unit than a lower pixels to units setting. Isn't it the other way round? Lower setting = larger object in the physics simulation (eg. setting it to 1 with a sprite that is 200 pixels tall will make the sprite 200 meter tall in the physics engine). \$\endgroup\$ – bummzack Sep 15 '14 at 7:22
  • \$\begingroup\$ Ah yes, you're right. Got that mixed up! Thanks for pointing it out. Edited my answer. \$\endgroup\$ – Cooper Sep 15 '14 at 11:08
9
\$\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\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.