When a script doesnt work in a new project when it has previously worked fine in many others, what exactly am i supposed to do!!
It gives this error (see attached)
and this is the script, which works fine everywhere else -
static var gotKey : boolean = false;
var key : GameObject;
//function to switch GUI Texture on / off
static function EnableTaggedGUITexture(tag : String, enable : boolean) {
//check for an object with a certain tag
var go = GameObject.FindWithTag(tag);
if(go) {
//if found, address its GUITexture component
var gt = go.GetComponent(GUITexture);
if(gt) {
// ..and enable it
gt.enabled=enable;
}
//if not found state that there is no GUITexture on the gameObject
else {
Debug.Log("Error: The GameObject does not have a GUITexture component to enable", go);
}
}
//if no tagged game object matching found, return following statement
else {
Debug.Log("Error: Could not find a GameObject tagged "+tag);
}
}
function Start(){
gotKey = false;
EnableTaggedGUITexture("KeyGUI", false);
Instantiate(key, GameObject.FindWithTag("KeyPlace").transform.position, GameObject.FindWithTag("KeyPlace").transform.rotation);
}
function OnControllerColliderHit (hit : ControllerColliderHit) {
//check and see if the collision has a tag called "key"
if (hit.collider.gameObject.tag == "key"){
gotKey = true;
EnableTaggedGUITexture("KeyGUI", true);
var keyClip = hit.collider.audio.clip;
var keypoint = hit.collider.transform.position;
AudioSource.PlayClipAtPoint(keyClip, keypoint);
Destroy (hit.collider.gameObject);
}
if (hit.collider.gameObject.tag == "health" ){
var healthClip = hit.collider.audio.clip;
var healthpoint = hit.collider.transform.position;
AudioSource.PlayClipAtPoint(healthClip, healthpoint);
Destroy (hit.collider.gameObject);
Health.health+= 20;
}
}
Help!