Getting Started with Tycoon Tile
What is Tycoon Tile
Tycoon Tile is a tile based terrain asset that allows you to create tycoon and city builder games quickly. It can be used in perspective or isometric camera view. Supports intuitive terraforming tools that recreate the classic tycoon game terrain mechanics. Adjust tile height per corner, create rolling hills or steep cliffs. Paint terrain with up to 65536 unique materials. Create water bodies with the click of a button. Kickstart your tycoon game development with Tycoon Tile now!
Features:
- High performance jobified unity job system burst compiled
- Low memory footprint
- Easily extendible with custom operations
- Ready to use out of the box
- Water support included
- Tested for terrain up to 2048x2048
- Supports up to 65536 unique materials
- Includes example runtime terrain generator
- Includes example user interface & terraforming tools
- Create custom terrain operations to adapt to your game's needs.
Installing Tycoon Tile
Tycoon tile requires a few packages to be installed from the package manager. To install the required packages, navigate to Window -> Package Manager
Make sure that the following packages are installed in your project:
- com.unity.collections (0.0.9 or higher)
- com.unity.mathematics (1.0.1 or higher)
The example scene makes use of the Post-Processing package (2.1.7), so if you want to import and use the example scene, make sure to install the Post-Processing package as well.
Other versions of the packages than the ones mentioned may work, however have not been tested before release. If you are experiencing any issues with more recent package versions then please contact me!
Setting up a scene
Setting up Map components
For a basic setup, create a new empty gameobject and attach the Tycoon Tile Map component. Here is a recommended set of values:
Next, add a Tycoon Tile Renderer component such that the terrain will be rendered.
We will need a Terrain Type Collection asset in order to tell the renderer how to render the terrain. You can create one by right clicking in the project window and selecting Create -> Tycoon Tile -> Terrain Type Collection
Give the collection a name (‘TerrainTypeCollection’ in this example) and assign it to the Tycoon Tile Renders’ Terrain Types field.
Now we need to assign some terrain types to the terrain type collection. You can create a new terrain type by right clicking in the project window and selecting Create -> Tycoon Tile -> Terrain Type Definition
Every terrain type definition needs to have a surface material and a cliff material assigned. The surface material will be used to render the terrain surface, while the cliff material will be used to render the tile cliff. Tycoon Tile comes with a grid shader that is compatible with the built-in Unity renderer, which was used for the materials in this example.
After creating a terrain type definition, add it to the list of definitions in the terrain type collection. The example scene has its terrain type collection configured as follows:
You need at least one terrain type definition in your collection. Lastly, assign a material to the water material and water cliff material fields. In this example, the same blue transparent material with a standard shader is used.
The water material will be used to render water surfaces. The water cliff material will be used for the vertical water mesh on the map edges.
Now the terrain is ready to accept operations scheduled via script and update its visuals. However, we still need to setup the camera and tools such that we can actually send these operations to the terrain. For more information about these tools, see the Example contents section.
Setting up camera and tools
The terraforming and painting tools both depend on the TycoonTileRaycaster component. The TycoonTileRaycaster is responsible for keeping track of terrain selection based on camera position and user input. It then informs the tools and their previewers about any selection changes. Tools such as the terraformer and painter can then use the OnSelectionChanged event to act upon selection changes and schedule operations on the terrain. The water tool and its previewer do not depend on the TycoonTileRaycaster, since they deal with floating point world positions (including vertical position) instead of tile positions in horizontal directions only.
In order to be able to use the terraforming tool, one needs to add the TycoonTileRaycaster component to the main camera gameobject of the scene. Then, add a TerraformingTool under Add Component -> Tycoon Tile -> Tools -> Terraforming Tool. In order to be able to preview your selection while terraforming, add a TerrainSelectionPreviewer under Add Component -> Tycoon Tile -> Previewers -> Terrain Selection Previewer. Without the previewer you can schedule terrain operations, but you won’t be able to see what your current terrain selection is. For the painting tool, the setup process is similar as described above, using the PainterTool and TerrainPainterPreviewer.
In the example scene, the camera object is configured as follows: