I need help. I have two classes, Warrior and Healer (for example’s sake.)
Both Classes use a random.range system to set starting attributes and gender. For example, the Warrior class is something like this:
public int gender;
public in health;
//set gender through if, return
//set health through if, return
Next, I have a menu system, and the goal is for the player to trade his coin for being able to recruit a random instance of either the Warrior or Healer (player’s choice)
Thus, I have corresponding buttons. The ‘Recruit Warrior’ Button and ‘Recruit Healer’ both have the RecieveCharacter.cs attached to their button, with a public function that checks which public variable has been set for adventurerClass. So it is something like this:
public string adventure class;
…
public void theFunctionTheButtonUses(){
if(adventureClass ==“Warrior”){
//generateclass
}
}
…and you get the idea. Now comes my question… I want to instantiate an instance of the class the player picks (either warrior or healer) and I want to ensure the stats are randomized like I put in my code. The classes work fine, and the button works fine. I’m not having problems with broken code… I just don’t know the syntax to implement my instance. I have an empty game object called ‘AdventurerGameObject’ set to 0,0,0 in my scenes. I wanted a class instance to spawn at runtime OnClick, but I don’t use prefabs. I wanted to class instance to directly be created as a child of the AdventurerGameObject. I also need to check for gender and set the according portrait and stats to display in a panel on it’s own, though I haven’t gotten to that point yet.
I’ve been looking for help in documentation and all I can find is instantiating objects from prefabs. Any help or direction towards a tutorial would help me. Thank you.