- Home /
Camera can see an Object
Hi, i've got a quetion. I have a boolean in my script, and i want my boolean to be true, if the Camera looks in the direction of an object. I already tried
if(gameObject.renderer.isVisible)
{
boolean = true;
}
else
{
boolean = false;
}
but, everytime i do that, the boolean will return as true (in every situation). Is there an other way, or am I doing something wrong?
but the boolean is returning true when im not even looking in the direction of it. I only testet it in the game-mode.
What brian means is that if you're seeing the gameoject in the scene view renderer.isvisible will return true. Try turning the scene view to look into nothingness or compile a build.
haha. im sorry, i didn't noticed i had a camera on my gameObject. $$anonymous$$y fault......
Ok now there are two options. 1. brian converts his comment to a question and you can accept it. 2. You close the question but please thumbs up brian's comment :)
Answer by roojerry · May 03, 2013 at 05:15 PM
from Renderer.isVisible
Also, when running in the editor, the scene view cameras will also cause this value to be true.
Do check that link as there can be other quirks to using isVisible. If you need a more precise solution because of those issues, feel free to ask again
Your answer
Follow this Question
Related Questions
Graphics raycasting if renderer in game object is seen and not occluded 1 Answer
Changing two different objects renderer colour 1 Answer
Renderer.isVisible always returning false 2 Answers
Duplicate everything in a set space in all directions? 2 Answers
How can i active again a render texture after set it to null ? 1 Answer