hey guys. i am having trouble wrapping my head around how i would do an inventory system. i do not want to have to code in every single item in my game. say the player can have swords: i want to be able to create a base class called item. this would have a few public members/variables including price (float), name (string) and GuiIcon (texture)
there would be another class called sword that would inherit this. the player would have a list of item objects.
this is where the problem is. i want to use the sword class as i would any other script that inherits monobehaviour… i want to be able to attach it to an object and then in the editor define all of those public variables. i’d create an empty game object, attach it to an empty prefab, attach the sword script to it, and fill out the paramaters (100, Dagger, daggerIcon, for example…). i can create many different swords with this method…but to get it to work this way, it would mean that the base class, item, would need to inherit monobehaviour. if i do that, all instances of item are no longer just data…theyve become game objects. if i want a player to have 5 daggers, i would need to instantiate 5 daggers, and add those game objects to the players list of item objects. (his inventory… List inventory). it seems really inefficient to do this…and wrong. i just need to store the data, i dont need game objects. (The gameobjects would be handy when the player DROPS an item from his inventory though. because it is already a game object i can just render it into the world and drop it next to the players feet)., if i DONT inherit from monobehaviour, i cant use the script on various different prefabs to create various different swords. i’d have to hard code every sword in the game.
i hope i am making sense here… there is alot on my mind right now…! haha…
i just need some help understanding the best way to go about this.