- Home /
GUI Problem
Hi, I wanna make a gui so that detects if a light is at 0 intensity, and if it is at that then it displays a text box saying "press f to turn on flashlight" cause its a dark room and da player would want to know they have a flashlight and how to turn it on, anyway here is the javascript i made but it says "It is not possible to invoke an expression of type 'float'." which i dont know how to fix since i am noob at scripting:
function OnGUI () {
if (light.intensity (0));
(GUI.Box (Rect (10,10,200,20), "press f to turn on flashlight"));
print("flashlight on");
}
thanks in advance!
Answer by syclamoth · Dec 19, 2011 at 02:04 AM
How about
if(light.intensity <= intensityThreshold)
if statements require a expression which evaluates to a boolean value. Calling a float like a function doesn't even make sense- hence the compiler error.
(intensityThreshold is a float value that you define in a public variable so it can be set up from the inspector)
I should point out that this script will only work for one light at a time, and only when attached to the same object as that light. It will not detect the total light level at any given position or object.