4
\$\begingroup\$

I follow the tutorial 2D Roguelike tutorial. I want to understand how happen that 10x10 board of 32x32 sprites covers screen perfectly? Like what does this depend on?

\$\endgroup\$
8
\$\begingroup\$

This depends on several things really.

First is the pixels per unit found in the sprite editor, which determines how many pixels there are for each 1 of Unity's distance units. So if you want your 32x32 sprites to be at 1,1 1,2 ect with no overlap, this should be listed as 32.

Next is the settings on the camera, which show a certain amount of the game world. For a 2d game, Orthographic is probably best. The size setting is what determines how many units the camera displays, being half of the size of the vertical viewing volume (horizontal comes from the aspect ratio).

Finally, there is the scale on the object itself. This is the multiplication of a single run. So if the object is 1 unit long, a scale of 2 would increase it to 2.

On another note, with regards to roguelikes, the more modern way to make them which that tutorial is too old to mention would be a tilemap. In this case, another value to be concerned about would be the cell size, which determines where in the world the tile is placed. A cell size larger than the tiles pixels to units will result in gaps between tiles, and a cell size smaller than the pixels to units will result in overlapping.

\$\endgroup\$
  • \$\begingroup\$ The 'size' camera property is what i missed from the beginning. \$\endgroup\$ – mirt Jul 12 '18 at 17:20
  • \$\begingroup\$ Not surprising, since it is hidden unless on Orthographic mode, and IIRC, even in 2d, the camera is by default in Perspective. \$\endgroup\$ – Imperial Justinian Jul 13 '18 at 11:07

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.