I am looking for advice on how to proceed, currently in my project all items extend from a base ScriptableObject called BaseItem, this class has a property that holds the ItemPrefab for when the item is spawned in-scene.
[CreateAssetMenu(fileName = "BaseItem", menuName = "Item/New BaseItem")]
public class BaseItem : ScriptableObject
{
public string name;
public string id;
[TextArea]
public string description;
public Sprite icon;
public GameObject ItemPrefab;
public virtual void Use()
{
}
public virtual string GetDescription()
{
return description;
}
public string GetName()
{
return name;
}
}
I also have "EquippableItems" that as you might have guessed are equippable by the player, these weapons/armour etc have "Rune slots" on them, where a player can slot in runes to alter the behaviour/stats of the equipment via the inventory.
The problem I have is, I am altering the Prefab of the weapon, when I only want this to effect the current item I'm modifying.
I know why this is occurring because I'm editing the prefab and not an instance of it, I know sort-of what I need to do to fix it, but I can't find many examples to learn from.
I belive I need some kind of Manager that handles creating specific instances of a prefab and assigning them an ID, but I do not understand how this would work for inventory items which is where you alter the runes.
Because;
A: all items are essentially "stateful" scriptable objects while in my inventory and
B: instantiating all the items in my inventory hiding them and referencing that instead seems like a silly way to go about it.
Example Scenario:
I have two metal katana's in my inventory, I right click one of the metal katana's and click "Manage Runes" and add a +5 Fire Damage rune, I "drop" both katana's so they are now spawned into the scene on the floor, both weapons have the +5 Fire Damage rune slotted.
How do I handle this scenario so only Katana #1 is slotted with the rune? I know it needs its own instance of that Prefab, but when do I create this while it's in-game but not in scene?
thanks for reading! Apologies I feel this question is rather poorly worded but If I had the correct vocabulary for wording this then I could've done a better job of googling/github..ing.