I would like to do a list like :
List<Item> items = new List<Item>();
With all differents types of items that inherit from the main “ITEM” class
potion : item
food : item
material : item
Each class has it’s own parameters and properties like potion has fillAmount etc… that are set to a random number each time to scene starts.
void Start(){
Potion p = gameObject.AddComponent<Potion>();
p.fillAmount = Random.Range(5, 50);
}
What I’ve seen is that if get an Item back like :
if(item[0] is potion){
print((Potion)item[0].fillAmount);
}
But this returns zero, any help?
Can’t this list store custom child class parameters?