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?
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.