- Home /
[javascript] detect when object is seen by camera, Renderer.isVisible not working
I'm trying to make a script that only runs a certain part if the gameObject is within the field of vision of the camera {probably should mention I'm working in 2d; I'm not necessarily looking for a script that detects if the gameObject has been obstructed}
I've been digging around & haven't found any straight forward answers, & it doesn't help that the manual gives no examples of code whatsoever >.>
Here's the code I thought would work:
if(Renderer.isVisible){
// do a thing here
}
It's giving me an error saying An instance of type 'UnityEngine.Renderer' is required to access non static member 'isVisible'.
I tried making renderer lower case
if(renderer.isVisible){
& it told me I'm using an obsolete scripting api. Does anyone know what I'm doing wrong? Any help is much appreciated ;-;
Your answer
Follow this Question
Related Questions
Renderer on object disabled after level reload 1 Answer
OnBecameVisible is not working correctly! 1 Answer
AnimationEvents firing if animation not visible? 1 Answer
Detect if entity is visible - renderer.isvisible will not work! 3 Answers
Hide gameobject until certain condition has been met,Hide an object until a condition is met. 2 Answers