So yeah, I’m trying to make something like this:
When player is touching the invisible box (no collider). GUI.Label shows on the screen. When he’s leaving the trigger, the label hides. The problem is that I should use function OnTriggerEnter, but for GUI I should use OnGUI. Any clue what I should do?
Scripts:
var Guiscript : image1 ;
function OnTriggerEnter (other : Collider)) {
if (Guiscript.enabled == true){
Guiscript.enabled = false;
}
else {
Guiscript.enabled = true;
}
}
}
Ok never mind it was my fault. I finally figured it out. I had some bodies of dead soldiers within the trigger area and this was setting it off on game start. Thank you for your help regardless
This can work for any guitext you have in the object
using UnityEngine;
using System.Collections;
using System;
using System.Text;
using System.IO;
public class Showtext : MonoBehaviour {
GUIText guiText;
// Use this for initialization
void OnTriggerEnter(Collider other) {
guiText.enabled = true;
}
void OnTriggerExit(Collider other) {
guiText.enabled = false;
}
a