- Home /
GUItexture not showing on runtime or trigger
hey devs how r u? I'm having some problem with enabling a GUItexture on the runtime in my game. the texture must appear when the player either collides with the door or when he picks up a cell but the texture does not appear on both sides I think it's an error in my HUDon function I dunno... so here:
TriggerZone Script:
function Start () {
}
function Update () {
}
function OnTriggerEnter (col : Collider) {
var lockedSound : AudioClip;
if(col.gameObject.tag == "Player") {
if(Inventory.charge == 4) {
transform.FindChild("door").SendMessage("DoorCheck");
} else {
transform.FindChild("door").audio.PlayOneShot(lockedSound);
col.gameObject.SendMessage("HUDon");
}
}
}
And this is the Inventory script:
static var charge : int = 0;
var collectSound : AudioClip;
var hudCharge : Texture2D[];
var chargeHudGUI : GUITexture;
function Start () {
charge = 0;
}
function Update () {
}
function CellPickup () {
HUDon();
AudioSource.PlayClipAtPoint(collectSound, transform.position);
charge++;
chargeHudGUI.texture = hudCharge[charge];
}
function HUDon(){
if(!chargeHudGUI.enabled){
chargeHudGUI.enabled = true;
}
}
Thanks in advance guys
Please format your code correctly on future posts. Fixed it for you this time.
what if you add some Debug.log messages to see if the proper functions are being called.
Also, have you check if you colliders as the "on trigger" enabled inside the inspector?
@Piflik 10x I just learned how to do that lol :P
@Vc$$anonymous$$ the trigger option is enabled in the inspector, the door is opening when the player collects all 4 cells so basically everything is working just right, when I check the GUITexture's box (the 1 at left of it's title in the inspector) it appears at the start of the game & works well. $$anonymous$$y goal is to make it appear only when the player enters the trigger without cells or when he captures 1 for the 1st time.