- Home /
Boolean while looking at a game object?
I want to make a true or false statement when looking at a certain object, for example a cube gameobject. When you look at the cube the boolean become true. When you look away the cube becomes false. Is this possible in a simple script?
Answer by robertbu · Mar 17, 2013 at 03:47 PM
Are you talking about a first-person or third-person game?
If you have just a single camera and you are talking about a first person game, you can checked the Renderer.isVisible flag for the object. You can also use these functions:
OnWillRenderObject, Renderer.OnBecameVisible, and OnBecameInvisible.
Note these methods of detecting if an object is "seen" will still return true even if the object is hidden behind another object.
Your answer
![](https://koobas.hobune.stream/wayback/20220613094551im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
The public bool will not change unless i set it 1 Answer
Why does this simple script not work????? 0 Answers
Boolean values not behaving as expected. Please Help?! 0 Answers
Boolean problem!! 2 Answers
Engine Only Returns Responses for False 2 Answers