How do I write a script that can cycle through hiding and showing of five objects. I've tried using GameObject.Find(Torso1) to find my objects and then renderer.enabled to hide and show it, not sure if i'm heading in the right direction. The script is attached to my camera.
At the moment my error message is "The name 'hide' does not denote a vaild type ('not found').
Any help would be much appreciated.
Thanks:)
var show : GameObject;
var hide : GameObject;
private var myInt: int = 1;
private var visible: boolean = true;
function Update() {
if (visible == true){
if (Input.GetKeyDown(KeyCode.D))
{
myInt++;
}
if (Input.GetKeyDown(KeyCode.A))
{
myInt--;
}
if (myInt == 1)
{
show = GameObject.Find(Torso1);
//show = GetComponent.();
show = renderer.enabled = true;
}
if (myInt == 2)
{
hide = GameObject.Find(Torso1);
hide = GetComponent.();
hide.enabled = false;
show = GameObject.Find(Torso2);
//show = GetComponent.();
show = renderer.enabled = true;
}
if (myInt == 3)
{
hide = GameObject.Find(Torso2);
hide = GetComponent.();
hide = renderer.enabled = false;
show = GameObject.Find(Torso3);
//show = GetComponent.();
show = renderer.enabled = true;
}
}
}
↧