0
\$\begingroup\$

I've got stuck with 'pixel per unit' parameters and object scale.

I've created two different sprites. A background picture, 1000x1000 pixels, and another one for a 'player', 200x200 pixels. I've added two empty game objects, with default transform, so positions are (0; 0; 0) and scale is (1; 1; 1). I added a sprite renderer to both of them, and assigned the required sprites. Both sprites have 1 pixel per unit.

And the 'player' in the scene looks much more bigger than the background.

I expect that if ppu=1, then the background would have a size of 1000 units, a player 200 units and it would be 5 times smaller.

What am I doing or understanding wrong? What is an actual object size?

\$\endgroup\$
  • \$\begingroup\$ I'm unable to reproduce the problem you're describing. Creating two sprites of the dimensions you describe, setting their PPU to 1 (don't do this in your real game, please), and assigning them to sprite renderers with default scale, I observe the background to be 1000 units wide, 5x larger than the 200-unit-wide player sprite. Can you provide a specific set of steps we can follow to reproduce this problem in a new empty project? \$\endgroup\$ – DMGregory Jan 6 at 0:42
  • \$\begingroup\$ @DMGregory thank you, I will try to do it again from scratch. Maybe I accidentally change some other settings. \$\endgroup\$ – Nikita Smirnov Jan 6 at 9:34
1
\$\begingroup\$

The problem was caused by manual replacing of .png picture in project's folder. At first time I didn't found a valid way to import an image as sprite, so I created a default one in Unity, which creates a sprite and a picture 1x1 pixels. Then I replaced it with my own picture, but metadata didn't change, and the Unity still worked with sprite like it is still 1x1 pixel, not 1000x1000, 200x200 etc.

The valid way to import a picture as sprite is just to put it to Assets folder in the project, or drag and drop a file to Assets folder in Unity.

| improve this answer | |
\$\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.