It throws no errors up for me but still when i start the game the battery 2d gui dissapears and when a walk into the battery nothing happens here is my player collisions script and my battery collect script.
private var doorIsOpen : boolean = false;
private var doorTimer : float = 0.0;
private var currentDoor : GameObject;
var batteryCollect : AudioClip;
var doorOpenTime : float = 3.0;
var doorOpenSound : AudioClip;
var doorShutSound : AudioClip;
function Update () {
if(doorIsOpen){
doorTimer += Time.deltaTime;
if(doorTimer > 3){
shutDoor();
doorTimer = 0.0;
}
var hit : RaycastHit;
if(Physics.Raycast (transform.position,
transform.forward, hit, 5)) {
if(hit.collider.gameObject.tag=="outpostDoor" && doorIsOpen ==
false){
currentDoor = hit.collider.gameObject;
Door(doorOpenSound, true, "dooropen", currentDoor);
GameObject.Find("Battery GUI").GetComponent(GUITexture).enabled=false;
}
}
}
}
function OnControllerColliderHit(hit: ControllerColliderHit){
if(hit.gameObject.tag == "outpostDoor" && doorIsOpen == false){
currentDoor = hit.gameObject;
Door(doorOpenSound, true, "dooropen", currentDoor);
}
}
function OpenDoor(){
audio.PlayOneShot(doorOpenSound);
doorOpen = true;
var myOutpost : GameObject = GameObject.Find("outpost");
myOutpost.animation.Play("dooropen");}function shutDoor(){
audio.PlayOneShot(doorShutSound); doorIsOpen = false;
var myOutpost : GameObject = GameObject.Find("outpost");
myOutpost.animation.Play("doorshut");
}
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)
and here is my battery script
static var charge : int = 0;
var charge1tex : Texture2D;
var charge2tex : Texture2D;
var charge3tex : Texture2D;
var charge4tex : Texture2D;
var charge0tex : Texture2D;
function Start(){
guiTexture.enabled = false;
charge = 0;
}
function Update () {
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;
}
}
asked
Mar 23 '10 at 08:34 PM
canihazaqueztion
1
●
1
●
1
●
1
All of your code segments need to be surrounded by
tags to make it easier to read.