- Home /
Duplicate Question
How do I check if a GameObject is visible by a camera?
I've noticed that this has been posted before, but they all seemed very outdated, so I was wondering if/hoping that it changed. I am looking particularly for JavaScript, so if you give an answer in C# it will be very difficult for me to make sense of it. I was wondering if I could check if a specific GameObject is visible by a specific camera, (if not, any camera) Hoping that the command will return either true/false, or a command that will test when something enters the camera, or leaves the camera.
Thank you!
Answer by robertbu · Aug 01, 2014 at 05:56 AM
This answer from 2009 is still valid today.
http://answers.unity3d.com/questions/8003/how-can-i-know-if-a-gameobject-is-seen-by-a-partic.html
Note that all these methods but GeometryUtility.CalculateFrustumPlanes method fire when any camera see an object. With CalculateFrustrumPlanes() and GeometryUtility.TestPlanesAABB() you can test if a specific object is in front of a particular camera.
There is one thing that was true in Unity 3.x days that may not be true today. In the editor, the scene camera counted as 'any camera' and therefore would cause the callbacks to fire or 'isVisible' to be true. I've had some things happen recently that indicate that may not still be true, but I've not run a detailed test.
Which makes this answer incorrect for the question asked.
Follow this Question
Related Questions
Check if is object in camera field and not covered by other object 0 Answers
How can I make a gameobject partially invisible by distance? 2 Answers
Unity3D scene not rendering objects in Game screen 3 Answers
Instantiated GameObject Not Rendering 1 Answer
How to create a new camera and NOT have it own the view (but still Find-able)? 1 Answer