So, I have two bits of code. One calls to another script to do something, and that script… Does something.
My error is that this:
void OnTriggerEnter(Collider Col){
if (inventory.charge == 4) {
transform.FindChild ("door").SendMessage ("DoorCheck");
if (GameObject.Find ("chargeHUDGUI")) {
Destroy (GameObject.Find ("chargeHUDGUI"));
doorlight.color = Color.green;
}
} else if(inventory.charge > 0 && inventory.charge < 4){
TextHints.SendMessage("I think it needs more power!" , "ShowHint", UnityEngine.SendMessageOptions);
} else {
AudioSource.PlayClipAtPoint (lockedsound, transform.position);
Col.gameObject.SendMessage("HUDon");
TextHints.SendMessage("This Door is locked, I need to power it!" , "ShowHint", UnityEngine.SendMessageOptions);
}
On TextHints.SendMessage, needs the string (The first line of text in the SendMessage) and the object, however, I’m not aware of what I need for those. Here’s the script it’s calling to:
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class TextHints : MonoBehaviour {
Text text;
public float timer = 0.0f;
// Use this for initialization
void Start () {
text = GetComponent<Text>();
}
// Update is called once per frame
void Update () {
if (text.enabled) {
timer += Time.deltaTime;
}
if (timer >= 4) {
text.enabled = false;
timer = 0.0f;
}
}
void ShowHint(string message){
text.text = message;
if(!text.enabled){
text.enabled = true;
}
}
}