Hi guys i created this script all it dose is it disables and enables a script. But the problem is if i press the button the script will go off as should but if i want to turn it on again i have to press the same key again now that works fine as well. Now the problem is the timing if i press the key i have to wait 2 or 3 seconds before i can press it again to enable or disable the script. Is there a way where i press the key right away after i pressed it with out the timing issue oh and yes i have to some time hold the key to enable the script and disable it. Here is the script:
var OnScript : boolean = true;
function Update()
{
if(Input.GetKey(KeyCode.K) && OnScript ){
OnScript = false;
GetComponent(AnimationScript).enabled = false;
}
else if (Input.GetKey(KeyCode.K) && OnScript == false ){
OnScript = true;
GetComponent(AnimationScript).enabled = true;
}
}
thank you in advance :)