I cant seem to figure out how to call the Toggle.isOn. Character walks on object and icon changes from grey to color. I figured this was the isOn command but keep getting. > Assets/personal/changeWeapons.js(52,34): BCE0019: 'isOn' is not a member of 'Object'.
here is the relevant stuff
var ExtinguisherIcon;
ExtinguisherIcon = GameObject.Find("ExtinguisherIcon").GetComponent.();
ExtinguisherIcon.isOn = true;
Looking on web, I've seen several ways people did it but I'm doing something wrong. I may be mixing up C# code with JS (I've only been at this a couple weeks). Here is everything on that script just in case that helps. Right now for testing the icon just turns on but i will make it it's own function after it works.
#pragma strict
var weapons : GameObject[]; // array of weapons
public static var extinguisher = false;
public static var teapot = false;
public var armGO : GameObject;
var anim: Animation;
private var state = 0;
var ExtinguisherIcon;
function Start(){
SelectWeapon(0);
armGO = GameObject.Find("Weapons");
anim = armGO.GetComponent.();
ExtinguisherIcon = GameObject.Find("ExtinguisherIcon").GetComponent.();
}
function Update () {
if(Input.GetKeyDown("1"))
{
armGO.GetComponent.().Play("armDown");
state = 1;
}
if(Input.GetKeyDown("2"))
{
if(teapot == true)
{
armGO.GetComponent.().Play("armDown");
state = 2;
}
}
if(Input.GetKeyDown("3"))
{
if(extinguisher == true)
{
armGO.GetComponent.().Play("armDown");
state = 3;
}
}
if (!anim.IsPlaying("armDown"))
{
if(state != 0)
{
SelectWeapon(state - 1);
armGO.GetComponent.().Play("armUp");
state = 0;
}
}
ExtinguisherIcon.isOn = true;
}
function SelectWeapon(index : int){
for(var obj:GameObject in weapons)obj.SetActive(false);
weapons[index].SetActive(true);
}
Thanks for the help.
↧