Hey,
So I’ve put together a script and works good but when I use the Debug.DrawRay I can see that when looking down the ray disappears. Any help?
#pragma strict
var showGUI : boolean = false;
var posMiddle = 0.0;
var posCenter = 0.0;
var tagCheck : String = "Wood";
function Start()
{
posMiddle = Screen.width / 2;
posCenter = Screen.height / 2;
}
function Update()
{
var hit : RaycastHit;
var foundHit : boolean = false;
foundHit = Physics.Raycast(transform.position, transform.forward, hit);
if(foundHit && hit.transform.tag == tagCheck)
{
showGUI = true;
}
else
{
showGUI = false;
}
Debug.DrawLine (transform.position, hit.point, Color.cyan);
}
function OnGUI()
{
if(showGUI)
{
GUI.Box (Rect (posMiddle - 75,posCenter + 20,150,25), "Press E To Pickup");
}
}