How to make a Camera a Main camera

Vector3.Magnitude(Camera.main.WorldToScreenPoint(f1.transform.position) - Input.mousePosition);

Im using the above code to get some distance with an GameObject called f1.First im using first person controller. Then my application works fine. But when i delete the first person controller and try to add just a camera below exception comes.

NullReferenceException UnityEngine.Camera.WorldToScreenPoint (Vector3 position)

What should i do?

You just need to tag it “MainCamera”, that’s all. Click on the Camera in your Hierarchy so its properties are brought up in the inspector, then change the Tag property right underneath the name field, so it says “MainCamera”. Then it will respond to Camera.main in your code.