unity iphone raycast problem

hi guys,

i’m trying to make a game in iphone using unity3d…i’m getting trouble when i make touch on the gameobjects…

here is my script…

//.cs

public RaycastHit hit;

void Update()
{

Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
if(Input.GetMouseButtonDown(0))
{
if(Physics.Raycast(ray,out hit,100))
{
Debug.Log("hitted object "+hit.transform.gameObject.name);
}

}
}

am getting the error as:

NullReferenceException: UnityEngine.Camera.ScreenPointToRay (Vector3 position)

well i have used the same script in my another scene…thats worked perfectly…but now its not working well…in briefly i have attached mesh colliders all of my gameobjects…

i have a board in my game with mesh collider attached…and lot of coins(like cylinders) in it…i want to touch that coins and wanna to get that coin name…thats it my problem…any one explain what kind of problem i have now…

thanks…

i have posted the same question in answers.unity3d.comhttp://answers.unity3d.com/questions/45397/unity-iphone-raycast-problem

Is there a main camera in your scene? If you replaced the default camera with a new one or changed the tag to something other than MainCamera then Camera.main will be null. The easiest way to fix this is to change the camera’s tag back to MainCamera, but if this isn’t possible, you could pass the actual camera into the script with a public variable:-

public Camera cam;
  ...

Ray ray = cam.ScreenPointToRay(Input.mousePosition);

ya correct andeeee…

i haven’t tagged my camera as into “main camera”…thank u for your reply…