Hey Unity Answers community,
Here’s my script at the moment:
#pragma strict
var other : GameObject;
var buttons : GameObject[];
private var randNumber: int;
function Start () {
other.SetActive(true);
for (var i = 0; i < buttons.Length; i++)
buttons*.SetActive(false);*
InvokeRepeating(“SwitchButtons”, 0.0, 5.0);
}
function SwitchButtons() {
for (var i = 0; i < buttons.Length; i++)
buttons*.SetActive(false);*
randNumber = Random.Range(0,buttons.Length);
buttons[randNumber].SetActive(true);
}
function Update () {
if(buttons[0])
{
if(Input.GetKeyDown(“q”));
other.transform.Translate(Vector3(2,0,0));
}
}
The issue is my variable (other) disappears once I go into play mode even though in inspector it’s right where I want it. What’s the issue?