i want to know what object is the closer to the camera to see

I have a camera with position and a vector rotation, and a list of objects in the scene. how can i tell what object the camera is most looking at?

is there a way to compare position and lookAt?
I am assuming i will have to loop the objects and compare a value any ideas?

thanks guys

1 Answer

1

To check the distance you can use Raycast. You will need the RaycastHit to get the info on the distance.

The problem here is that the closest object may not be the object that takes up the most of the view of the camera. That would require some other calculation.