Raycast not working(code in post)

Hello,

I would like for a guiTexture to display when the camera gets within a certain distance of my book. I can get the guiTexture to display when I click a button, but I want it to display when I face my book.

function Update()
{

	var hit : RaycastHit;
	
	if(Physics.Raycast (transform.position, transform.forward, hit, 3))
		{
			if(hit.collider.gameObject.tag == "book")
			{
				guiTexture.enabled = true;
				//hit.collider.guiTexture.enabled = true;
				//print("Casting Ray");
			}
		}
}

Appreciate any help.

Try Debug.DrawRay() Unity - Scripting API: Debug.DrawRay
To see where the Ray is really going.

I did, but I see no Ray.

I got it to work now, sadly, the script was in the wrong place…as usual.