lundi 13 février 2017

Select one random name from an array in void Update() in unity

I am calling a function inside void Update, this function has to get one random name when I run the code, but the text where I'm trying to display the name is also changing per frame. I know it is basic, but I'm really having a hard time here, hope someone answers. I've already looked on google and everywhere I just can't find the right answers. Thank you in advance.

string[] firstchair = "Sophieee|VIP1|VIP2|VIP3|VIP4".Split('|');
void Update(){
    displayName();
}

public void getRandomName(){
    System.Random rnd = new System.Random ();
    FirstPerson = firstchair [rnd.Next (firstchair.Length)];
}
public void displayName(){
        int k = 0, i = 1, j = 2, h = 3;
        if(tableNameText.text == "ITA Server 2/2 001" && maxPlayerNumber == 4){
        miniatures[i].SetVariablesforBots(FirstPerson, AvatarScreen.instance.femaleAvatars[0], ""); 
}
}




Aucun commentaire:

Enregistrer un commentaire