// Jimmy Vegas Unity Tutorial // This Script enables the makeshift button by the door //This goes on the player It's called "PlayerCasting" static var DistanceFromTarget : float; var ToTarget : float; //how far it is to the target function Update () { var hit : RaycastHit; if (Physics.Raycast (transform.position, transform.TransformDirection(Vector3.forward), hit)) { ToTarget = hit.distance; DistanceFromTarget = ToTarget; } } //--------------------------------------------------- //This goes on the Trigger Object import UnityEngine.UI; var TheDistance : float = PlayerCasting.DistanceFromTarget; var TextDisplay : GameObject; function Update () { TheDistance = PlayerCasting.DistanceFromTarget; } function OnMouseOver () { if (TheDistance <= 2) { TextDisplay.GetComponent.().text = "Press Button"; } } function OnMouseExit () { TextDisplay.GetComponent.().text = ""; }