I know there is alot of threats about taking booleans from other scripts, but mine just seem to dont work as it should and i cant find the mistake for myself. I have a flashlight attached to first person controller named flashlight.js
var on : boolean = false;
function Update() {
if (zibintas.paimtas == true) { //will check if true
if(Input.GetKeyDown(KeyCode.F))
on = !on;
if(on)
light.enabled = true;
else if(!on)
light.enabled = false;
}
}
and i have an object named zibintas with script named zibintas.js attached to it :
static var paimtas : boolean = false;
var player = GameObject.FindGameObjectWithTag("Player");
function OnTriggerEnter (player : Collider) {
if(player.tag=="Player") {
if (paimtas == false) {
paimtas = true;
GameObject.Find("zibintas");
Destroy (gameObject);
}
}
}
I need for flashlight to check if zibintas boolean named paimtas == true; and if true, the flashlight should work normaly but if i write the line if (zibintas.paimtas == true) it just doesnt do anything even tho paimtas changes to true;