Hi, I'm having trouble figuring out a way to randomise the text of a 3d text object. I'm aiming for having a selection of 5 different strings for the computer to choose from. I'm then thinking that having a random float calculate between 0 and 5.
I can't figure out how to have the number that the float randomly chooses be assigned to the 5 different string variables.
Basically, anyone want to add to this script to see if they can figure out how to select a random string and assign it the the 3d text game object (npcChitChat var)
Thanks in advance
//random text variables
Private var PrefabNum : float =0; var textLine1 = "hello world"; var textLine2 = ""; var textLine3 : String = "three"; var textLine4 : String = ""; var textLine5 : String = "";
function OnTriggerEnter (myTrigger : Collider) {
//checks to see if the players character is in the trigger area. If so, then it starts the trigger
if(myTrigger.gameObject.name == "Player")
{
//prevent the script from firing the text multiple times, this checks whether the timer has begun.
if(npcChitChat.active == false)
{
//random text generation
//displays the text
Debug.Log("NPC is Chit Chatting");
npcChitChat.GetComponent.<TextMesh>().text = textLine1;
npcChitChat.active = true;
//changes camera
if(cameraZoom == true)
{
Debug.Log("camera wants to zoom");
cameraObject.active = true;
}
//invoke the text so that it disappears after the var timeToWait
Invoke("StartChitChat", timeToWait);
}
}
}
function StartChitChat ()
{
Debug.Log("NPC is Chit Chatting");
npcChitChat.active = false;
if(cameraZoom == true)
{
Debug.Log("stopped the camera zoom");
cameraObject.active = false;
}
}