So im reading this book Unity 3.x Development Essentials. And im stuck.
Right now im working on GUIText. And im trying to change it. When i come to the closed door the message shows up “Damn it! It’s locked… Maybe that generator needs power”
and after when i pick up first power cell and come back to the door it should show “This door won’t budge…guess it needs fully charging- maybe more power cells will help…”
I checked my script many times and could not find anything. Plz help thanks.
using UnityEngine;
using System.Collections;
public class TriggerZone : MonoBehaviour {
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
public AudioClip lockedSound;
public GUIText textHints;
public Light doorLight;
void OnTriggerEnter(Collider col){
if(col.gameObject.tag=="Player"){
if(Inventory.charge==4){
transform.FindChild("door").SendMessage("DoorCheck");
if(GameObject.Find("PowerGUI")){
Destroy (GameObject.Find("PowerGUI"));
doorLight.color=Color.green;
}
else if(Inventory.charge > 0 && Inventory.charge < 4){
textHints.SendMessage("ShowHint",
"This door won't budge..guess it needs fully charging- maybe more power cells will help...");
transform.FindChild("door").audio.PlayOneShot(lockedSound);
}
}else{
transform.FindChild("door").audio.PlayOneShot(lockedSound);
col.gameObject.SendMessage("HUDon");
textHints.SendMessage("ShowHint", "Damn it! It's locked.. Maybe that generator needs power");
}
}
}
}