I’m working on a mechanic that causes objects to interact when they’re seen by the player’s first person camera.
So far, I’m using a “LookReaction” script that goes on any object that will react to being looked at. It uses GeometryUtility.CalculateFrustumPlanes and GeometryUtility.TestPlanesAABB to check if the object intersects with the camera frustum. If it does, it uses Physics.Linecast from the camera to the object’s position to tell if there’s another collider in the way. If the Linecast returns the desired object’s collider, the object counts as being looked at.
It works great, except for objects that are partially occluded by other objects. Since the line is cast to the center of the object, it doesn’t count as being in line of sight if less than half is poking out from behind another object.
What’s a good solution for catching objects that are mostly blocked from view? Thanks for any help!