Spawning GameObject from class array Javascript

Hey hey Unity Anwsers! For a project we are trying to spawn a singular character from a list of 24 predefined characters. There is a code where we set the characteristics of the characters, with each variable being an enum (except for the character - GameObject)

class Character {

var gender : Gender;
var hair : Hair;
var pet : Pet;
var item : Item;
var clothes : Clothes;
var character : GameObject;
..
}

And there is now a second script where at random, it selects one member of the 24 character cast. The question is, how do we access the GameObject variable from the class in order to spawn it? The code we have so far is:

var activeChar : boolean;

function Start () {

activeChar = false;

var setChar = AllCharacters.Length;
}

function Update () {

if(activeChar == false) {
	var randChar = Random.Range(0, AllCharacters.Length);
	Debug.Log (randChar);
	activeChar = true;
	}
	
if(activeChar == true) {

	Instantiate(
}
}

Thanks a lot in advance!

Hmm let me give it a try,

#pragma strict

//In Inspector, drop all 24 characters here.
public class AllCharacters[] ;

var activeChar : boolean;
 
 function Start () {
 
 activeChar = false;
 
 var setChar = AllCharacters.Length;
 }
 
 function Update () {
 
 if(activeChar == false) {
     var randChar = Random.Range(0, AllCharacters.Length);
     Debug.Log (randChar);
     activeChar = true;
     }
     
var randomCharacter = AllCharacters(Random.Range(0, 25));
 if(activeChar == true) {
 
     Instantiate(randomCharacter);
 }
 }

I’m new myself so I’m not sure if this will work :confused:

I feel like I’m really close now; this is the code:

#pragma strict

var AllCharacters : Character[];

var toSpawn : GameObject;

var activeChar : boolean;

function Start () {

activeChar = false;

var setChar = AllCharacters.Length;
}

function Update () {

if(activeChar == false) {
	var randChar = Random.Range(0, AllCharacters.Length);
	Debug.Log (randChar);
	activeChar = true;
	
	}
	
if(activeChar == true) {
	var x : int;
	x = randChar;
	Instantiate(AllCharacters.character[x], Vector3.zero, Quaternion.identity);
}
}

But Unity states “BCE0019: ‘character’ is not a member of ‘Character’.” which I don’t understand since “character” is one of the variables of the “Character” class… any ideas?