(I'm newbie) I have lot of Scriptable Objects which hold Tile data (forest, desert, etc.) every SO have attributes (like movement cost). When my Game Object moves I check which type of tile he stepped. It works. Now I would like to check what is the movement cost of the tile where he stepped. How can I do it?
(I can do it if I declare all the SO at the beginning like:
public TileData forestData;
public TileData desertData;
and so on. And the check the type where the GO stepped. But if I have 100 different tile type it means 100 declaration and 100 if statment. So how can I do it easier? Thanks.
CodePudding user response:
I recommend you to use List for this task
public List<TileData> Tiles = new List<TileData>();
or
[SerializeField] private List<TileData> Tiles = new List<TileData>();
Some helpful links:
https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.list-1?view=net-7.0 https://docs.unity3d.com/ScriptReference/SerializeField.html