using UnityEngine;

public class CameraRaycast : MonoBehaviour
{
    public Camera cam;

    void Update()
    {
        // check if camera is looking at something
        Ray ray = cam.ViewportPointToRay(new Vector3(0.5f, 0.5f, 0));
        RaycastHit hit;
        if(Physics.Raycast(ray, out hit))
        {
            // if object has a tag, we can do something
            if (hit.transform.CompareTag("important"))
            {
                print("looking at: " + hit.transform.name);
            }
        }
    }
}
