I am using the Water.cs script in Reflective mode as a mirror and was wondering if it’s possible to detect when an object is visible (being reflected) by the plane. I can see that the script uses a LayerMasks so I can choose which layers are culled, but is there a way to check if a specific object is being drawn?
I have tried using the regular Visibility checkers (OnBecameVisible/OnBecameInvisible as well as the IsVisibleFrom script on the Wiki) but as Water.cs uses cameras in an unconventional way these don’t seem to work.
Any help would be great.
Thanks in advance!
Thanks for the script, ZefanS. However, it only checks if the object is on screen in the usual way. That is, if the object is in front of the camera. If we have a mirror placed in front of the camera which reflects an object which is at the camera’s side (so not within the camera’s view frustum), it will fail the screenpoint check you have set up.
I suspect one way would be to somehow detect which objects are being reflected by the Cameras in the m_ReflectionCameras dictionary in the Water.cs script. However, how to approach this is a little beyond my level of experience - any suggestions would be great.
Hi @asimov , Did you find a solution? I am stuck on a similar problem where i have to detect if an object is being seen from a mirror reflection