- Home /
How to change boolean value once on KeyDown
In my every project switching between booleans is too fast. Boolean has "true" value for 0.1 second.
if (vision.collider.tag == "LightButton")
{
if (Input.GetKeyDown(KeyCode.Mouse0))
{
JEEP.GetComponent<Driving>().LightsOn = !JEEP.GetComponent<Driving>().LightsOn;
}
}
Comment
I don't quite understand, do you mean you want the boolean to change after .1 seconds? Or some other specific time length? If so, you would want to use a coroutine. You can learn more about these at: https://docs.unity3d.com/$$anonymous$$anual/Coroutines.html