Ok so heres my code from this section:
var Cam : Camera;
public var distanceaway;
function Start()
{
distanceaway = 0;
}
function OnGUI()
{
GUI.Label (Rect (10, 20, 100, 20), "distance: "+ distanceaway);
}
function Update()
{
var ray = Cam.ScreenPointToRay (Input.mousePosition);
var hit : RaycastHit;
if (Physics.Raycast (ray, hit, 1000))
{
distanceaway = hit.distance;
}
}
When i run it occasionally it will display the distance but most of the time nothing is displayed after "distance: " just every now and then when scanning the environment itll flash up the distance. Any one got any ideas?