Golden Skull Studio Extension for Grids


Below is a package that allows you to use Grids with the hex and isometric tiles designed by Golden Skull Studios. In particular, it calculates suitable sorting order for tiles so that they are rendered in the correct order, even when stacked vertically.

The package contains:

  • A custom cell component that supports various features of the tile set:
    • Sprite and color
    • Height offset
    • Vertical stacking
  • Two default prefabs (one for hex and one for iso) that uses the component above, and are suitable for use with grid builders.
  • A custom GridBehaviour that does basic initialization of cells and allows you to add additional initialization.
  • 3 custom initialization scripts (for each tile type):
    • One that selects a random sprite from a list, and selects a random height offset or stack height.
    • One that uses patterns (grid coloring functions) to select sprites and stack heights.
    • One that takes offsets and stack heights from a height map, and selects sprites based on a height map too.
  • Two example scenes (one for each tile type) that shows how to set up your grids using the scripts above. Each scene has examples for all three custom initialization scripts.



How to import the packages

  1. In a new project, import Grids and the tile set that you want to use.
  2. Select all the sprites, and on the import settings, set the Pixels Per Unit to 1. This ensures unity units correspond to pixels. If you don’t do this, many examples won’t work.
  3. Import the package below. All the files are in the folder GoldenSkullGridExtensions.

If you only import one tile set, one of the example scenes won’t work. You can safely delete it. Everything else should work.

How to setup a scene to use these tiles

  1. Make sure your camera is orthographic, and that it’s size is half the screen height that you want to design for.
  2. Add a grid builder to your scene as normal. On an empty game object in your scene, add either the FlatHexTileGridBuilder or the DiamondTileGridBuilder component. Link in the HexCellPrefab or IsoCellPrefab, and configure the grid as you like.
  3. Add the GSHexGridBehaviour or GSIsoGridBehaviour component to the same game object.
  4. Optionally, add custom initialization scripts. You can use one of those we provide, or make your own. Configure them as you like.
  5. Optionally, configure the properties on the cell prefab:
    1. Tweak the Center Offset to control how coordinate gizmos are displayed.
    2. Tweak the Cell Dimensions to get a tighter or looser fit. The dimensions are the dimensions of the “flat” part of the cell (the part of the cell that is visible when all the heights are the same).
    3. Tweak the Stack Offset to determine how far tiles are displaced when stacked vertically.

How to use the custom initialization scripts

The custom initialization scripts we provide are examples of how you can initialize cells for your game. In general, you would not use these for your game, as you probably want to use your own logic. These examples should provide you with a good starting point though.

screen_10screen_22Random Sprite

This script selects sprites randomly, and assigns height offsets and stack heights randomly too. If max stack height is 1, then tiles won’t be stacked, as is shown on the far left. If the max height offset is 0, tiles won’t be offset, as is shown on the near left.

Patternscreen_23 screen_13

This script selects sprites and stack heights based on a color function. Any repeating pattern can be configured this way. To understand how the three numbers determine the pattern, see What are grid colorings? Make sure you have enough sprites to support the pattern, otherwise you will get exceptions.

screen_28 screen_20Height Map

This script selects sprites and heights based on a height map. Generally, you would either keep max stack height 1 (shown far left), or keep max scale 0 (shown near left). If you want the bottom layer to be completely flat (for water, for instance), tick the Flat First Level box. You can tweak the height of this first level, which is useful for liquids too. The frequency determine how the image is sampled. Tweak this value for denser / sparser sampling. Make sure the image you use is tileable, and has Read/Write enabled, and is sampled using bilinear filtering.

Implementing your own logic

Generally, you would probably implement your own cell so that it can handle any extra information you need for your game. For example, you may want to implement a tile type property that you can set in code that would automatically select the right sprite. You can then query this code in your game logic to work out what can happen on this cell. For more information see Making your own cells.

You would also probably want to implement your own initialization script. The easiest way to do this is to extend from GridBehaviour, and put all your logic in a method called Init. Note: normally grid initialization happens in the InitGrid method. However, this method is already defined in GSGridBehaviour, which sends a message to the Init method. For more information see Working with GridBehaviours.



1 thought on “Golden Skull Studio Extension for Grids”

  1. Pingback: Golden Skull Studios Extension for Grids | Gamelogic

Leave a Reply

Your email address will not be published. Required fields are marked *

Scroll to Top