Question by
trollywally361 · Nov 29, 2017 at 02:16 AM ·
lightenable and disable script
I want to make a flashlight toggleable when you press the letter "f" HELP!!!,I want to make my flashlight toggleable in C# by pressing "f" HELP!!!
public Light FL;
// Use this for initialization
void Start()
{
FL = GetComponent<Light>();
FL.enabled = !FL.enabled;
}
// Update is called once per frame
void Update()
{
if (Input.GetKeyDown("f") && FL.enabled == true)
{
FL.enabled = !FL.enabled;
}
else if (Input.GetKeyDown("f") && FL.enabled == false)
{
FL.enabled = FL.enabled;
}
}
Comment