Hi. I’m trying to write a script where I can keep pressing space and I don’t know how. I have it set up so when you press space for the first time it makes lastPress = 0. But then it just skips over the middle input,
Text instruction;
string lastPressed;
// Use this for initialization
void Start () {
instruction = GetComponent<Text>();
}
// Update is called once per frame
void Update () {
if (Input.GetKey(KeyCode.Space)) {
instruction.text = "It is 6:35 am";
lastPressed = "1";
}
if (Input.GetKey (KeyCode.Space) && lastPressed == "1") {
instruction.text = "You must wake up";
}
}
}