|
Hello, I have a "Character" script and inside that, I have a "Attributes" class. What I want to do is to create a random number of characters, add their attributes (I have already create the algorithm for this), store those characters into an array and finally when I chose a character from a menu add him/her into the World by creating a new GameObject. I'm not looking for a working code. I just want to hear different opinions and then decide what is the best way to achieve such thing. Thank you for your time.
(comments are locked)
|

C# or Javascript?
I'm programming in Javascript. But it doesn't really matter. What I really want to find out is the method of doing this.
You can add a random number of elements to a list that holds a struct of whatever attributes you need. When you populate the list you can access the constructor of the struct and assign those attributes random values. Then when you actually add the character to the game you can copy the attributes from the list to the character's component.
It's crude, but should work.