Hi, i have a class Warrior that inherits from a class Character, these warriors have to be saved on a Dictionary.
Dictionary<string,Character> characters = new Dictionary<string, Character>();
To save them i’m using:
private void createWarrior(string name){
warrior = gameObject.AddComponent<Warrior>();
warrior.setWarriorAttributes(name,1000,1,3);
characters.Add(name,warrior);
}
But with that each time a create a new Warrior a new Component is Add to a game object, and at this point i only want to save them in the dictionary. But i can’t use ScriptableObject because later i have to instantiate prefabs with the script Warrior and he has to be inherits from MonoBehaviour so i can do it.
With what i replace AddComponent ? I tried use new:
Warrior = new Warrior()
It works, but unity gives me a warning, and i read that’s not recommend.
Sorry for my english, google translate.