- Home /
How to set parameter to tiles
Hi, I'm using tilemap. I want to set "move cost" to each tile type. What is the smart way to get the cost? I'm using TileMap.GetTile (tile Position).name and compare the string with Dictionary I made. But I feeling this isn't smart way to implement.
Is there any good way to link Tilemaps.Tile with specific data? Thanks.
https://code2d.wordpress.com/2020/07/21/tilemaps/
Here is a set of tutorials on rendering to unity's tilemap
Answer by Statement · Nov 02, 2020 at 12:07 PM
I havent used the Tilemap system but these docs suggest you can subclass TileBase
Answer by superjustin5000 · Nov 02, 2020 at 02:51 PM
You can store a separate two dimensional array of your custom tile object that map back to the tile map based on x,y. So you can reference them like MyTile tile = myTiles[y][x]
But honestly based on docs @Statement shared, Unity has a way to implement tile map with your own custom tile. That would probably be most people's preferred method.
Is that possible to use custom tile with layouting tiles through tipe pallet? I'm planning to create quite number of maps, so I want to keep map creation workflow simple.
I haven't played with Unity's built in tilemaps enought, but here is a video that might help you get started. https://www.youtube.com/watch?v=XIqtZnqutGg And you don't have to use scriptable objects, but he basically maps tile types to a class attributes. And you can always check which tile your character is on, and if it matches the specific tile type from the class, do whatever that type is supposed to do.