Im having a problem with the battery GUI part. The GUI wont charge for some reason? When the door is approuched the gui and text hint will appear, the batteries can be picked up and make a noise. but the textures dont seem to be changing for some reason. Does anyone know how to fix this? thanks.
these are the scripts being used
private var doorIsOpen : boolean = false;
private var doorTimer : float = 0.0;
private var currentDoor : GameObject;
var doorOpenTime : float = 3.0;
var doorOpenSound : AudioClip;
var doorShutSound : AudioClip;
var batteryCollect : AudioClip;
function Update () {
if (doorIsOpen) {
doorTimer += Time.deltaTime;
if (doorTimer > doorOpenTime) {
Door(doorShutSound, false, “doorshut”, currentDoor);
doorTimer = 0.0;
}
}
var hit : RaycastHit;
if (Physics.Raycast (transform.position, transform.forward, hit, 5)) {
if (hit.collider.gameObject.tag == “outpostDoor” doorIsOpen == false BatteryCollect.charge >= 4) {
currentDoor = hit.collider.gameObject;
Door (doorOpenSound, true, “dooropen”, currentDoor);
GameObject.Find(“PowerGUI”).GetComponent (GUITexture).enabled=false;
}else if (hit.collider.gameObject.tag==“outpostDoor” doorIsOpen == false BatteryCollect.charge < 4) {
GameObject.Find(“PowerGUI”) .GetComponent (GUITexture) .enabled = true;
TextHints.message = “The door seems to need more power…”;
TextHints.textOn = true;
}
}
}
/*
function OnControllerColliderHit ( hit : ControllerColliderHit) {
if (hit.gameObject.tag == “outpostDoor” doorIsOpen == false) {
currentDoor = hit.gameObject;
Door(doorOpenSound, true, “dooropen”, currentDoor);
}
}
*/
function Door(aClip : AudioClip, openCheck : boolean, animName : String, thisDoor : GameObject) {
audio.PlayOneShot(aClip);
doorIsOpen = openCheck;
thisDoor.transform.parent.animation.Play(animName) ;
}
function OnTriggerEnter (collisionInfo : Collider) {
if (collisionInfo.gameObject.tag == “Battery”) {
BatteryCollect.charge++;
audio.PlayOneShot (batteryCollect);
Destroy (collisionInfo.gameObject);
}
}
@script RequireComponent (AudioSource)
…
static var charge : int = 0;
var charge4tex : Texture2D;
var charge3tex : Texture2D;
var charge2tex : Texture2D;
var charge1tex : Texture2D;
var charge0tex : Texture2D;
function Start(){
guiTexture.enabled = false;
charge = 0;
}
if(charge == 1){
guiTexture.texture = charge1tex;
guiTexture.enabled = true;
}
else if(charge == 2){
guiTexture.texture = charge2tex;
}
else if(charge == 3){
guiTexture.texture = charge3tex;
}
else if(charge >= 4){
guiTexture.texture = charge4tex;
}
else{
guiTexture.texture = charge0tex;
}