Not Sensing while touching the Object

Hi All,

i am facing strange problem here.In my project i am using some of the objects.In that i am using Bee image object[.fbx file].My problem is while touching that object it was not sensing the touched object.It was sensing the background object.Here i am using the following code for sensing the objects…

function Update()
{
if(Input.GetMouseButton(0)||Input.GetMouseButton(1))
{
var hit : RaycastHit;
ray = Camera.main.ScreenPointToRay(Input.mousePosition);

if(Physics.Raycast(ray,hit))
{

var hitobjname=hit.collider.gameObject.name;
print(“hitobjname”+hitobjname);

var hittransformname=hit.transform.name;
print(“hittransformname”+hittransformname);

}
}
}

just i want to know whether this is image problem or code problem.Please reply.

Thanks in Advance,

Do you have a collider attached to the object and is it in front of the background?

Hi yes,

Now its working great.i forget to attach the collider in my game object.Thanks for your reply.

Thanks&Regards,