Search Unity

Pixels To Unit noob question :)

Discussion in '2D' started by Yonben, Mar 13, 2014.

  1. Yonben

    Yonben

    Joined:
    Jan 5, 2014
    Posts:
    8
    Hi all :)

    So I started using Unity a few months ago, and I made little games (idle game, Pong etc..), and I want to start on a bigger project: a 2D action platformer inspired by Risk Of Rain :).

    However, as I wanted to start to work with characters, I got troubles with the pixel per unit setting. The default is 100, but because it's a "big game" for me, I don't want to have to change things in the future, and then have to change the whole game :/.

    So how do I set a good pixels per unit setting ?

    Thanks for your help!
     
  2. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    The default of 100 means that a texture 100 pixels big becomes a sprite that's one unit big. It's generally best to have sprites be somewhere around one unit big, or at least not super far from that, since that's good for physics and other things. Rather than having huge numbers, which can be problematic.

    --Eric
     
    Most_Incredible likes this.
  3. herpanda

    herpanda

    Joined:
    Jan 1, 2014
    Posts:
    27
    If you're going for pixel art, I'd set it to a power two so that things line up nicely in the editor's grid. I have mine set to 16 pixels per unit when importing, and my tiles are 16x16 px, so they line up on the grid. That's about all the input I have :p I'm also pretty new.
     
  4. Yonben

    Yonben

    Joined:
    Jan 5, 2014
    Posts:
    8
    So if I understand well, I have to set the pixels to unit to the size of my tiles, so one unit is one grid square right? Btw what tile editor are you using to design your maps ?

    Thanks for the answers!
     
  5. Invertex

    Invertex

    Joined:
    Nov 7, 2013
    Posts:
    1,550
    If you're doing a very large level, I would say to do it 2x that. So 128 pixels is 1 unit for example. All your sprites should have the same pixels to units, or else they won't be sized properly relative to eachother. You can set up in your Snap settings so that when you hold CTRL, you're only moving the tiles by single units or half units, thus making sure your tiles are always lined up as you move and place them around. (though when you initially put one in the scene, you'll need to set it's position to 0,0 first, but duplicating and moving while holding ctrl will then keep all subsequent copies lined up.
     
  6. Yonben

    Yonben

    Joined:
    Jan 5, 2014
    Posts:
    8
    Thanks! But when you say I need to have the same pixels to unit for all my sprites, you mean for my tiles AND for my characters (and whatever other sprites I would use in my game) ?
     
  7. Invertex

    Invertex

    Joined:
    Nov 7, 2013
    Posts:
    1,550
    Yes, any sprite, if you want them to be the same relative size to eachother that you designed them in Photoshop or whatever app. Of course, this isn't an absolute rule, if you have a sprite you want to be even larger or smaller without scaling it, then feel free to adjust the pixels per units, it's not going to hurt anything.
     
  8. Yonben

    Yonben

    Joined:
    Jan 5, 2014
    Posts:
    8
    Kk got it, because I'm making my prototypes with OpenGameArt Sprites so finding everything at the same size is not that easy :p