Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Unity Scale Units Tiles

Discussion in '2D' started by JeremyBenson11, Dec 6, 2016.

  1. JeremyBenson11

    JeremyBenson11

    Joined:
    May 9, 2013
    Posts:
    37
    I'm messing around with Unity with a little more math skills than I had in the past, but still not really getting the entire units issue. Right now I see that Unity has a default camera of 5, which is about 1 unit high. I guess a 24px tile is about 24/100 on a unit? One unity unit is 1 meter, so the tile is about 13 feet?

    lol, what ever that means.

    Anyway, I guess I should be asking is what is a good tile size? Why do people say to chose a size that is a multiple of 2 when they can never fill a unit?
     
    Last edited: Dec 6, 2016
  2. JeremyBenson11

    JeremyBenson11

    Joined:
    May 9, 2013
    Posts:
    37
    Last edited: Dec 6, 2016
  3. JeremyBenson11

    JeremyBenson11

    Joined:
    May 9, 2013
    Posts:
    37
    Sorry. Got one more post. Maybe someone could add this into the lesson. I've got a simple scene with two blocks that are 1 unit, with 100 as the unit size. The camera is 5. How come the camera view running on 1200x800 is different than what it shows in the editor?

    The black lines show where view starts when run after a build.

    https://postimg.org/image/5069xtpef/
     
  4. GooseNinja

    GooseNinja

    Joined:
    Sep 14, 2012
    Posts:
    45
    Your tiles can be whatever size you want, and you can set it to be 1 unit in Unity.

    Here I have a square. The scale is 1x1x1 making it 1 Unit.



    The sprite is just 4px by 4px, but the sprite config is configured to be 4px per unit.



    I also have another sprite; that is 32px by 32px, and it's set to be 32px per Unit. Making it the same size as the 4x4 tile.


    So regarding the size, just use what you are comfortable with using. If I'm working on something alone, I use 16x16 or 32x32 and just set the pixel per unit to one of those, depending on the game.
     
  5. GooseNinja

    GooseNinja

    Joined:
    Sep 14, 2012
    Posts:
    45
    I'm guessing you have the Game View set to Free Aspect, try changing the resolution or aspect ratio to see something different.
     
  6. JeremyBenson11

    JeremyBenson11

    Joined:
    May 9, 2013
    Posts:
    37
    Ah, you're right about all that. Genius. I knew I wouldn't start understanding this without a tutor on those issues. It's greatly appreciated. Assume that I make a game with 16:9, can you point me to a tutorial that talks about scaling graphics for the resolution? I assume every sprite would have to be scaled, or does one just scale the camera alone?

    One other issue. I have a 24x24 tile that I set to 24px per unit, but when I build the game an look the highest resolution for my screen the tile looks a bit sheered.

    Edit:

    I guess the main reason is that the brick graphic just sucks, lol. I added a better graphic from the web, and it does look better, so that's got to be one problem. Another issue with the new brick from the web, is I get this bloated feeling. It seems everything is a bit too zoomed?

    Is this a graphics issue, resolution issue, camera issue, or something else?
     
    Last edited: Dec 6, 2016
  7. GooseNinja

    GooseNinja

    Joined:
    Sep 14, 2012
    Posts:
    45
  8. JeremyBenson11

    JeremyBenson11

    Joined:
    May 9, 2013
    Posts:
    37
    Sure, thanks for the share. I have a question about the content of the article, though.

    "On an orthographic camera, the orthographic size dictates how many units in world space the screen’s height is divided into. So on a screen height of 1080 with orthographic size of 5, each world space unit will take up 108 pixels (1080 / (5*2)). It’s 5 * 2 because orthographic size specifies the size going from the center of the screen to the top."

    - Here we're saying resolution affects how man pixels are in a Unity unit? I guess if you have a sprite that is 100px and you have the unit size set to 100 in the editor, the size per unit will change again depending on resolution of the screen?

    Sorry, once again really slow with the math, lol.

    The second question is, what is meant by "orthographic size specifies the size going from the center of the screen to the top."?

    Does this mean the feild of view of the camera is half the screen, or the size only specifies half the world view in units?
     
  9. GooseNinja

    GooseNinja

    Joined:
    Sep 14, 2012
    Posts:
    45
    The article I posted before, is talking about how to make use Unity to make a Pixel Perfect game.
    There is a discussion on it here: https://forum.unity3d.com/threads/pixel-perfect-sprites.444385/
    I recommend checking it out if you want to know more about that in details.

    If your camera has an orthographic size of five, then it counts five units up and down from the center.
    This will make your game always have a total of ten units from the top of your screen to the bottom.
    Like this:

    And no matter how high or low the resolution of your screen is, it will always be like that.
     
    heosuaxongdzolua likes this.