Hi I’m trying to have a point light come on and stay on as a key is pressed and held down…but when that key is released the light should go off…here is the code I’m using…right now it comes on but when i release the key it stays on. …any help?
using UnityEngine;
public class FlashLight : MonoBehaviour
{
public Light FlashLightObject;
private bool LightEnabled = false;
void Update ()
{
if(Input.GetButtonDown("Flashlight"))
{
LightEnabled = !LightEnabled;
FlashLightObject.enabled = LightEnabled;
}
}
}