Search Unity

Tile Map How do I set the scale of a tile?

Discussion in '2D Experimental Preview' started by VinnieH01, Jul 31, 2016.

  1. VinnieH01

    VinnieH01

    Joined:
    Sep 3, 2014
    Posts:
    32
    How do I change the scale of my tile (Like you do when you change the scale of a Transform component)?

    Scale.png

    I cant find anything like this on my tile objects.
     
  2. Jay-Pavlina

    Jay-Pavlina

    Joined:
    Feb 19, 2012
    Posts:
    195
    Scaling is done with a Matrix4x4. You can set it with TileMap.SetTransformMatrix or TileData.transform.
     
  3. VinnieH01

    VinnieH01

    Joined:
    Sep 3, 2014
    Posts:
    32
    @Jay-Pavlina Where would I do this exactly, is there no way to do it in the inspector (Like scaling up a gameobject)?
     
    Mitcha47 likes this.
  4. Johaness_Reuben

    Johaness_Reuben

    Unity Technologies

    Joined:
    Jan 27, 2016
    Posts:
    253
    Are you trying to scale just one tile on the tilemap or your tile set to be scaled?
     
  5. VinnieH01

    VinnieH01

    Joined:
    Sep 3, 2014
    Posts:
    32
    I'm trying to scale every tile so that they fit into a 64 by 64 grid even though the graphics are 16 by 16 pixels (I still want the pixels per units at 1)
     
  6. Johaness_Reuben

    Johaness_Reuben

    Unity Technologies

    Joined:
    Jan 27, 2016
    Posts:
    253
    Not sure if this is an ideal solution.
    Select the tile asset and set the transform values.
    Set Flags to Lock Transform
    upload_2016-8-4_0-44-23.png

    Currently the Tilemap Palette will not adjust to the size, so to select the tile click in the middle of the image.
    I'm curious as to why you're using these values. Could you share a little on what you're doing and why?
    Cheers
     
  7. keely

    keely

    Joined:
    Sep 9, 2010
    Posts:
    966
    Can you give more insight why you insist on pixelPerUnit=1 and fitting 16x16pixel assets into 64x64 world unit grid?
     
  8. VinnieH01

    VinnieH01

    Joined:
    Sep 3, 2014
    Posts:
    32
    @keely @Johaness_Reuben First I set the cameras size to be the screen height / 2. I also offset the camera position by 0.1 in the x and 0.1 in the y. This removes all pixel streatching (http://i.imgur.com/cslZfEg.png). Then I set my pixels per unit on all my assets to 1 and then scale them to the approprite size using the transform options. This makes every unity unit one pixel on my screen. This gives me pixel pericise control of the positioning of my sprites (As long as I move using transform.Translate() or transform.position += ...). I also round the position of moving objects (also to remove pixel streatching). I created my own collision system using raycasts and kinematic ridgidbodys so I dont have to use the physics system. This setup is great for pixel art games since I can for example fine tune the speed of objects to remove jerkyness/choppyness and I overall have alot more control.
     
  9. VinnieH01

    VinnieH01

    Joined:
    Sep 3, 2014
    Posts:
    32
    @Johaness_Reuben Yeah, I agree its not and ideal solution (It works though I guess). If you belive its a good enough feature maybe you guys can create a easyer to use and better solutiuon to this. Something like "the normal transform scaling tools" and fix so that the pallet dosent totally mess up. Anyway thanks for all the help. :D
     
  10. keely

    keely

    Joined:
    Sep 9, 2010
    Posts:
    966
    I'm assuming you want x4 pixelart (one texel is four screen pixels).

    pixelsPerUnit=0.25 produces exactly the same rendering outcome than using 4x scaling matrix.

    Some differences in scripting:
    - Transform local space calculations differ (easy to match, though)
    - Transform scale affects children whereas pixelsPerUnit doesn't
    - Perhaps something else I'm missing?

    In any case, sounds like you are fond of your approach and don't want to change already working systems. Scaling per Tile asset like suggested is unfortunately your only option if you want to have grid size differ from your asset size.
     
  11. VinnieH01

    VinnieH01

    Joined:
    Sep 3, 2014
    Posts:
    32
    @keely @Johaness_Reuben I've got no problem scaling every tile asset. It seems to work pretty well, only problem is the pallet. If you can fix that, this would be a good solution. One thing I dont really understand is the flags on the tiles (Override Transform, override color, none etc). Can anyone explain?
     
  12. starrtennis

    starrtennis

    Joined:
    Jun 20, 2018
    Posts:
    25
    One solution is to make a tilemap, set the size of the tiles to automatic, then the first tile you drag and drop into the editor will determine the size of the tiles.
     
unityunity