Ok, I am a bit confused, and what I have read until now does not help a lot (but maybe I’m not asking right). I am learning Unity by creating a dungeon crawling RPG. It uses classes (and extensions) for mobs, players, items, everything. Now we have some of the following classes:
Item:MonoBehaviour → Equipable :Item → Weapon:Equipable
Similarly we have Character:MonoBehaviour → Player:Character, Npc:Character
Now I got these classes all filled in with variables and everything. The Player class adds a n input movement controller while the Npc one adds AI, Items have sprites etc. I am even using generic empty prefabs for players and items to simplify some parts.
Now my problem is, when it’s time to add all that stuff to the game (as game objects), what’s the best way to do it? I cannot obviously do it in the constructor, because it returns an object from that class, not a game object. Do I add a “spawn” function for players for instance, which does that? When a player drops an item from an inventory, do I do the same for that?
I don’t want a lot of objects in my game scene, so I like to keep stuff in arrays and use physical (game object) representations when I must. Can anyone guide me here?
Edit: To make this clearer:
A class is a blueprint for an object and the constructor is how the object is built. I want to use this logic for game objects. Can / should I?