Tiny Town

What is a block?

Introduction

Blocks represent any object that can be placed down on the grid. Different blocks will have different stats, size, appearance and behaviour. The only behaviours that are implemented in the template are the way blocks are being placed down (whether it can be rotated of if it should spawn multiple blocks at once etc ...).

There are 5 default types of blocks:

Buildings: A building is placed down with one click and can be rotated.
Zone buildings: A zone building is automatically spawned when creating zones.

Zones: A zone is placed down by dragging the mouse over several tiles and spawns Zone Buildings.
Paths: A path is placed down by dragging the mouse from one tile to another, will spawn on the shortest path between the two.

Nothing: These buildings won't be referenced outside the database. 

TT_Block class

Whenever you create a new block, you have to create a child class of the TT_Block. This means every block has its own blueprint from which you can add your own logic, meshes particle effects etc ... The TT_Block parent class will enable the block to be placed down properly on the grid but also to be properly referenced in the user interface.

To learn more about how to implement new blocks please see this tutorial.

Zones & Tile IDs

Every block occupies a "zone" of tiles. This zone is made up of all the tiles that are being covered by the block when it is placed down. Each block's zone's size is set via a database, and should be set depending on the mesh's size. A zone is defined by two tile ID's (called TileA and TileB) and can only be shaped as a rectangular. Zones are essential for the template to remember where blocks are placed down and what size they are. The following shows how these work withing the template.

Last updated: August 2019
  • GitHub
  • Sketchfab
  • LinkedIn
  • Twitter