1
\$\begingroup\$

I'm new to game development as a whole, so forgive me if this is an idiotic question in itself, but I want to use a sprite sheet where the entire sprite sheet's dimensions are 104x144, and the dimensions of an individual "pose" of the sprite is 26x36. If I can use this sprite, and I'm asking if I can, what Pixels Per Unit would I put? Again, I have absolutely no idea how this works, and I'm probably being a huge idiot about this entire thing.

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

Leave the pixels per unit at its default value.

Just below those options is a button labeled "Sprite Editor". Click this button to open the sprite editor.

In the top left corner of the sprite editor, click the button labeled "Slice".

Select type "Grid by Cell Size".

Enter pixel size X: 26, Y:36

Click the "Slice" Button

Click "Apply" in the top right corner and close the sprite editor.

EDIT: Rereading, I realize this answer does not answer your title question. Yes, you can use rectangular (and other shaped) sprites. The pixels per unit is unrelated to sprite shapes and should either left at its default value (in most cases, but not always) or set on all sprites to a common value in a tile based game.

| improve this answer | |
\$\endgroup\$
  • 1
    \$\begingroup\$ The default value is indeed not a bad starting point, but it won't be right for all non-tile-based games. So I'd caution against advice that says to always leave it there unless you're using tiles. \$\endgroup\$ – DMGregory May 12 at 17:27
  • \$\begingroup\$ Good point, I'll add a caveat \$\endgroup\$ – sirreldar May 12 at 17:45
1
\$\begingroup\$

This looks like a question you can answer by trying it!

Import the sprite sheet into Unity. Observe that there are no error messages, your game still builds and runs correctly, and your computer does not catch fire.

Modern devices can handle non-power-of-two textures just fine, as long as you're not using mipmaps, which usually for pixel art sprites you won't be. Unity also has the ability to re-pack these sprites into atlas textures to work more efficiently. And the size of an individual sprite within the sprite sheet doesn't matter at all, since the polygon it's being drawn on is allowed to cover as much or as little of the texture space as you want.

As a general rule: always try the thing first, to verify whether there is a real problem that you need to spend time asking about. Much of the time, what you try first will be good enough to continue progressing other parts of your game.


Regarding Pixels per Unit, remember that this is not related to the number of pixels in the image. It's related to how many pixels make up one logical building block of your world.

Let's say you're making a tile-based game. The logical unit of your game is then the size of one tile - that lets you position your tiles at nice clean integer positions, and reason about things like "a dash that moves 3 tiles needs to travel a distance of 3.0 units in world space". In that case, if your tile is 16 pixels, then 16 Pixels Per Unit makes sense. If a tile is 32 pixels, 32 Pixels Per Unit makes sense. No matter what the overall dimensions of the sprite sheet are as a whole.

We haven't seen your character in the context of your world, so we cant speculate whether the full 26x36 dimensions of its pose make up the right logical unit for your world. In some games, characters are larger than the game's logical unit, overhanging the edges of the tile or their collision representation. In other games, characters are smaller than the game's logical unit, fitting inside a tile with room to spare around.

| 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.