Search Unity

Make tile take up 4 grid cells

Discussion in '2D' started by Prince_John, Apr 3, 2019.

  1. Prince_John

    Prince_John

    Joined:
    Mar 25, 2019
    Posts:
    3
    Hi!

    I am trying to create a basic tower defense game where I have set up my cell size to be 0.5 X and 0.5 Y (so that the player can place their towers more freely, think WC3).

    This causes problems when I later in the game wants to check if a grid cell is occupied, because some cells will seem to be taken, but actually are not.

    Here's an image to illustrate my problem:

    upload_2019-4-3_8-33-56.png

    The black square is rendered over 4 cells, but only 1 of the cells are occupied (the white square in the lower left corner of the black square).

    Have anyone else faced this problem and knows how to solve it? :)

    Thanks in advance!
     
  2. beanie4now

    beanie4now

    Joined:
    Apr 22, 2018
    Posts:
    311
    Change your sprite Import Settings change your Pixels per unit to 1/2 of what it is now
     
  3. Prince_John

    Prince_John

    Joined:
    Mar 25, 2019
    Posts:
    3
    Thanks for your reply! This will only affect the size of the sprite, but not actually how many grid slots it will occupy.
     
  4. RidgeWare

    RidgeWare

    Joined:
    Apr 12, 2018
    Posts:
    67
    In my tilemap game, I maintained a 2D array in the code which defined whether a grid cell was empty or occupied.

    It would be very easy to place an object in one cell and then tell all 4 cells in the array to be occupied.
     
  5. Prince_John

    Prince_John

    Joined:
    Mar 25, 2019
    Posts:
    3
    Thanks for your reply. I am also starting to realize that my use case for the built in grid is not possible to accomplish, so I think I will have to implement something myself, as you are suggesting. :)