public GameObject playerCamera;
publich float threshold = 10f;
void Update() {
Ray ray = new Ray(playerCamera.transform.position, playerCamera.transform.forward);
RaycastHit hit = new RaycastHit();
if(Physics.Raycast(ray, out hit, 1000f) {
if(Vector3.Distance(playerCamera.transform.position, hit.point) < threshold) {
Debug.Log("Object " + hit.collider.gameObject.name + " is within threshold.");
}
}
}