- Home /
Question by
KingKongFu · Nov 21, 2012 at 04:13 PM ·
inputswitchif
Input using the same key twice
ok what i am trying to do is to get user input using the same key two or threes time to go though a selection process. What i got so far works to a degree but when i press the H button it just continuous on its merry way and not asking for input the second time. I tried Input.GetDown and Input.GetKey both dont work. Im using a if statement would a switch be better? Thanks for any help with this
Here is the code for the selection process
if(Input.GetKeyDown(KeyCode.B))
{
//this set timescale to 0
sliderError = true;
Debug.Log("B " + errorS);
}
//make the choice
if(Input.GetKeyDown(KeyCode.H) && !errorS)
{
//Time.timeScale = 1;
sliderError = false;
correctionSelect.enabled = true;
errorS = true;
//deploy = true;
}
if(Input.GetKeyDown(KeyCode.H) && errorS)
{
Debug.Log(errorS);
Time.timeScale = 1;
sliderError = false;
deploy = true;
}
Comment
Answer by krewnel · Nov 19, 2013 at 02:10 AM
Was errorS initialized at declaration? ie. bool errorS=False; as opposed to bool errorS; lacking initialization prevents you from ever making it into either of the if(...&&errorS) because errorS is neither True or False.