Hello,
I would like my enemies to drop some items when they die.
To do so, I created a class, LootTable, which contains a container (a List of items along with a probability for each item) , and the logic (a Drop() function that returns me a List of items that are dropped). Every kind of enemy will have a loot table associated and will be able to generate drops from it.
Then, my abstract Enemy class that is extended by each of my enemy scripts has a public static LootTable lootTable. What seems to be left is linking my items prefab and these LootTables in the Unity editor, and assigning probabilities.
But my LootTable won’t show in the Unity editor when I click on a GameObject that extends my Enemy class, and it seems that the “static” keyword causes this problem.
However, since I do not want to instantiate my LootTable everytime I instantiate an Enemy in my scene, I really want this Loot Table to be static for each enemy type.
For example, my “Goblin” enemy will have a LootTable containing a “Goblin Dagger” (along with its probability) and a “Ruby”, and another enemy “Sorcerer” will have a LootTable containing “Wand” and “Gold”. My “Goblin” prefab should hold my static LootTable and it should be editable in the editor, but I definitely do NOT want this table to be instantiated for every single Goblin in my scene.
What would be the proper way to implement this in Unity, since this static variable (LootTable) does not want to show up in the editor ?
Thanks for reading, and happy coding