I’m starting a new project, and I have run into an issue, this is my 1st time with tiles, and I need to give tiles different properties. For instance I want to give some tiles a resource value, for instance a “rock tile” would have ore as a resource. I can only add scripts to the tile map, which would give all the tiles the same properties.
You can create tiles classes deriving from the tilebase class, starting like this :
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Tilemaps;
[CreateAssetMenu]
public class BlockTile : TileBase
{
You’ll have to override some of the functions in there.
Putting in there a reference to an enum containing the names of each resource value this type of tile holds, or a flag system if a tile can contain multiple resources at once, or anything you like actually.
How do you “mine” a resource that is in a tile ? If you click on it or something, then you actually know how to get a particular tile in your tilemap, you could create a “map” class holding all the data that you can’t acheive to store directly on tile in it, referenced with x and y coordinates, and call both the script on your tilemap that destroys the tile, and the script on the class you created to add some more logic.
I’ve just started a tilebased game and am not sure yet what are the best practices when it comes to do so though