Ok so i have this generator that will spawn a random prefab with random stuff. I just cant work out how to add “text” to the strings. So to add a list of names. E.G Bob, Frank and Dave. (i’m also struggling with how to update the GUI as well)
var enemyPrefabs : GameObject[]; // Array of different Enemies that are used.
var spawnPoints : Transform[]; // Array of spawn points to be used.
var Name1Choices : String[]; //how do i store names here: e.g Bob, frank, dave
var Name2Choices : String[];
var Backstory1Choices : String[];
var Backstory2Choices : String[];
var Backstory3Choices : String[];
var Name1;
var Name2;
var Backstory1;
var Backstory2;
var Backstory3;
var mission : boolean = false;
var money : float;
function Start ()
{
MissionGen();
}
function MissionGen ()
{
if( !mission )
{
var pos : Transform = spawnPoints[Random.Range(0, spawnPoints.length)]; // Randomize the spawnPoints to instantiate enemy at next.
var obj : GameObject = enemyPrefabs[Random.Range(0, enemyPrefabs.length)];
Instantiate(obj, pos.position, pos.rotation);
Name1 = Name1Choices[ Random.Range( 0, Name1Choices.length ) ]; //Randomly Generated Name
Name2 = Name2Choices[ Random.Range( 0, Name2Choices.length ) ]; //Randomly Generated Name Part 2
Backstory1 = Backstory1Choices[ Random.Range( 0, Backstory1Choices.length ) ]; //Randomly Generated BackStory Part 1
Backstory2 = Backstory2Choices[ Random.Range( 0, Backstory2Choices.length ) ]; //Randomly Generated Backstroy Part 2
Backstory3 = Backstory3Choices[ Random.Range( 0, Backstory3Choices.length ) ]; //Randomly Generated Backstory Part 3
mission = true;
GameObject.Find("Name1").guiText.text = Name1;
}
else
{
Invoke( "MissionGen", 30.0f );
}
}
function Check ()
{
var BadGuyCheck : GameObject = GameObject.FindGameObjectWithTag( "BadGuy" );
if ( BadGuyCheck == null )
{
mission = false;
money += Random.Range(1000,10000);
yield WaitForSeconds (30);
Invoke( "MissionGen", 30.0f );
}
}