So, I have the item code as follows:
using UnityEngine;
[CreateAssetMenu]
public class Item : ScriptableObject{
public string name = "Dagger";
public Sprite sprite;
public int maxQuantity = 9;
public string description = "An iron dagger";
public enum ItemType {
Quest, Weapon, Helmet, Armor, Boots, Usable
}
public ItemType itemType;
public virtual void Use() {
Debug.Log ("Used item");
}
public virtual void OnEquip() {
Debug.Log("Equiped item" + this.name);
}
}
This code is an extended version of Unity’s Adventure Game tutorial at Unite, I have created the inventory that is fully functional as I need it, however, I want to create item scripts which are deriving from my Item class and have them function just as any other item. So I want to have, for an example, a public class HealthPotion which derives from Item, and this needs to have an override Use function. How would I go about writing this code? If I just do the health potion like this:
using UnityEngine
public class HealthPotion : Item {
public override void Use() {
Debug.Log("Do something");
}
}
Then, it probably won’t work for reasons I don’t know.