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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

I can't create a grid of hexagonal tiles

Discussion in '2D' started by Pixel_Paws, Apr 27, 2020.

  1. Pixel_Paws

    Pixel_Paws

    Joined:
    Apr 26, 2020
    Posts:
    4
    As a first step in creating a demo first game, I want to create a grid of hexagonal tiles, view them from top down, and have them change colours when I click on them.

    I believe I need to use Tilemap for this, but I have two problems:
    1) The Tilemap does not seem to be visible
    2) There does not seem to be a way to set the size of the tilemap
    3) I don't know how to access the individual cells from the tilemap.

    There's also the possibility that Tilemap is not the right class for this at all.

    Some advice would be appreciated :confused:
     
  2. japhib

    japhib

    Joined:
    May 26, 2017
    Posts:
    65
    It’s definitely the right solution for tilemaps in general.

    The tilemap object doesn’t really show up until you add tiles to it. You can do that using the Tile Palette window (Window -> 2D -> Tile Palette). First click the button to create a new tile palette object, then create tiles by dragging sprites into the tile palette. Then you can just paint those tiles onto the tilemap in the editor window.

    Accessing individual tiles in the tilemap, depending on what you want to do, but most useful are the Tilemap.GetTile and Tilemap.SetTile methods.
     
  3. Pixel_Paws

    Pixel_Paws

    Joined:
    Apr 26, 2020
    Posts:
    4
    OK thanks, I'll try that.