Raycast help needed

hello can you help me, i dont know how to use the raycast!, i have this code but when i click an object , it dont do nothing…

function Raycast (ray : Ray, out hitInfo : RaycastHit, distance : float) : bool
{
var ray = Camera.main.ScreenPointToRay (Input.mousePosition);
var hit : RaycastHit;
if (collider.Raycast (ray, hit, 100)) {
Debug.DrawLine (ray.origin, hit.point);
print("it works");
}

}

Moderator Edit by HiggyB: I updated your title, all caps is shouting and it’s best to use something a bit more descriptive than just “Raycast”. Also, wrap any code bits in a [ code ]…[/ code ] block (remove the spaces) for nicer formatting.

You say that you have that code but then when you click on an object nothing happens, which leaves me wondering: how/when/where are you ever calling your Raycast function? If you don’t call it of course it won’t be triggered, and we can’t help you without knowing how/when/where you call it. More code please? :slight_smile: