I need some help putting an array together so when I press Q it will choose one of the rooms and then place it where I told it to go.
public var button : boolean;
private var enter : boolean;
var particle : ParticleSystem;
var RoomArray : String[] = ["room", "room2", "room3", "room4"];
var chosenRoom : String;
var room : GameObject;
var room2 : GameObject;
var room3 : GameObject;
var room4 : GameObject;
function Update (){
if(button)
{
}
if(Input.GetKeyDown("q") && enter){
button = !button;
animation["Push"].wrapMode = WrapMode.Once;
animation.Play("Push");
particle.Play();
room.transform.position = Vector3(0,0,20);
room2.transform.position = Vector3(0,0,30);
room3.transform.position = Vector3(0,0,40);
room4.transform.position = Vector3(0,0,50);
}
}
function ChooseRoom()
{
chosenRoom = RoomArray[Random.Range(0, RoomArray.length)];
Debug.Log("chosenRoom " + chosenRoom);
}
function OnGUI(){
if(enter){
GUI.Label(new Rect(Screen.width/2 - 75, Screen.height - 100, 150, 30), "Press 'Q' to change door");
}
}
function OnTriggerEnter (other : Collider){
if (other.gameObject.tag == "Player") {
enter = true;
}
}
function OnTriggerExit (other : Collider){
if (other.gameObject.tag == "Player") {
enter = false;
}
}