loading level problem

i have a script that makes the GUI box go away at a certain range, but it never goes away!

var target : Transform;

function Update () {
var other = gameObject.GetComponent("GUI Style Script");

if ( Vector3.Distance(target.position, transform.position ) < 1) {
other.enabled = true;
}
if ( Vector3.Distance(target.position, transform.position ) > 1) {
other.enabled = false;
}
}

1 Answer

1

You could make a simple boolean that turns true or false when it is invisible/in view. Then on OnGUI, have it inside of an if statement. That’s how I generally cover things like this.

Can you please write out a script of it