I need to be able to get some GUIText to display when my Player collides with a floor panel (called “Warehouse Floor End” and only object in scene with that name). It doesn’t matter if the text is in a button/box as of code or a GUIText GameObject (have one in scene called “Well Done Message” and again is only object in scene with tha name.
P.S. It doesn’t matter what format the script is in (Java or C#)
using UnityEngine;
using System.Collections;
public class messagebox : MonoBehaviour {
public Transform other;
void OnGUI() {
if (other) {
float dist = Vector3.Distance(other.position, transform.position);
if(dist < 10 ){GUI.Box (new Rect(0,0,100,100),"Well done!!");
}
}
}
}
This is a c#script, add this to the floor panel and set the dist to what ever eg <5 <1 ect. Once you attached the script to the floor panel, in the inspector click the other and select your player (your character controller, ie first person controller ect)