I am spawning my tiles randomly on start, here’s a simplified version of what I’m doing.
for (int x = 0; x < gridSizeX; x++)
{
for (int y = 0; y < gridSizeY; y++)
{
tileMap.SetTile(new Vector3Int(x, y, 0), groundTileBase);
}
}
I would like to have custom data in the groundTileBase tile, walk speed would be a good example.
How can I go about putting custom data into the groundTileBase?
I see many tutorials on custom tile scriptable objects, but they all seem to presume the use of a tile palette, which I am not using since I spawn the entire world through code.
Can anyone direct my on how to put custom data into my tiles when spawning them in this way?
Instead of using Tile (which actually IS derived from a ScriptableObject), you can create your own derivation of Tile such as RazputinTile and give it extra data fields.
Now you can create instances of those on disk, OR… you can use the single “base” one from the disk and at runtime inject fresh information into it.
The catch is that as you create the field of tiles, or rather RazputinTiles, you would need to be sure to do these things:
have a reference to your groundTileBase (now a RazputinTile)
instantiate a fresh copy of it:
var copy = Instantiate<RazputinTile>( groundTileBase);
Thanks for the response, this will be good for standard scriptableobject stuff, like the walkspeed I mentioned.
However I’m thinking more for data thats editable during runtime, so changing one scriptable would change them all no? And wouldn’t be good for what I guess I actually want
I think a better example of what I want is the ability to flag the number of times a tile has been changed during world generation
It’s pretty cool… those copies can still be double-clicked on to see and edit them in the editor, but they die when you stop the game, unless of course you do standard savegame stuff, in which case this tile data just becomes part of your saved state that you collect and write to disk and read back in.