accessing camera from anther gameobject, not working

Hi,
I tried the following code on update(),

convertedVector=GameObject.FindGameObjectWithTag("camera").GetComponent<Camera>().ScreenToWorldPoint(new Vector3(Input.mousePosition.x,Input.mousePosition.y,camera.nearClipPlane+10.0f));

But unity is giving me a error like this,

MissingComponentException: There is no 'Camera' attached to the "whatTheFuck" game object, but a script is trying to access it.
You probably need to add a Camera to the game object "whatTheFuck". Or your script needs to check if the component is attached before using it.
gameobjtest.Update () (at Assets/scripts/gameobjtest.cs:15)

camera is attached to a gameobject tagged “camera” and the refering script is attached to a gameobject called “whatTheFuck”. Now I am not trying to access any camera attached to “whatTheFuck” gameobject, rather I am trying to access camera from another gameobject. But unity is saying me electric. What is causing the problem?

The main reason of why my code did not work is because of:

camera.nearClipPlane+10.0f

Here nearClipPlane is referring to clip plane of this gameobject’s camera component. But there is no camera attached to this gameobject. Camera is attached to a gameobject with camera tag. So we have to refer that gameobject. Thus in stead of using:

camera.nearClipPlane+10.0f

We have to write like,

GameObject.FindGameObjectWithTag("camera").GetComponent<Camera>().nearClipPlane+10.0f;

This will work just fine.

I know I am late, but I think I just figured it out.

Make sure the Game Object you want to see through has the “Player” Tag

Also,

Make sure the camera attached to that Game Object has the “Main Camera” Tag

It just worked for me, no need to write extra code, no errors.
Hope this helps!