- Home /
              This question was 
             closed Aug 05, 2013 at 10:41 PM by 
             ryisnelly for the following reason: 
             
 
            The question is answered, right answer was accepted
 
               Question by 
               ryisnelly · Jul 31, 2013 at 11:56 PM · 
                toggleflashlightflicker  
              
 
              Flash light toggle problem
so i wrote this out but having a few problems when i turn the flashlight on it flickers when i try to toggle it on, and its a 50/50 chance that it will stay on, any ideas how i could correct it so its either on or off with out the flickering?
thanks
using UnityEngine; using System.Collections;
public class FlashLight : MonoBehaviour {
 private bool FlashLightOn = false;
     // Use this for initialization
 void Start () {
 
 }
 
 // Update is called once per frame
 void Update () {
 if(Input.GetKey("x") && FlashLightOn == false){
         FlashLightOn = true;
         light.intensity = 2;    
         
     }
         else if(Input.GetKey ("x") && FlashLightOn == true){
         FlashLightOn = false;
         light.intensity = 0;
 }
} }
               Comment
              
 
               
              $$anonymous$$aybe you meant to use Get$$anonymous$$eyUp
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                