Skip to content Skip to sidebar Skip to footer

Input Not Recognised From Touchpad

I am trying to extend this Roll-a-Ball tutorial to include a timer and allow the user to try again by tapping the touchpad whether they win or run out of time. This works as expect

Solution 1:

Put a Debug.Log in SetCountText method, and output the value of count count. You are probably never hitting the 12 point mark. Make sure all your collectibles have the tag " Pick Up".

Update You should listen for player input in Update method. FixedUpdate and any other functions that execute as part of Fixed Update will miss the player input if it happens between two FixedUpdate calls.

So change your Update and GameOver method as follows:

void Update() {
    if (gameOver) {
        if (Input.GetMouseButtonDown(0)) {
            Application.LoadLevel(0);
        }
    } else {
        timeLeft -= Time.deltaTime;
        timerText.text = timeLeft.ToString("0.00");
        if (timeLeft < 0) {
            winner = false;
            GameOver(winner);
        }

    }

}
void GameOver(bool winner) {
    gameOver = true;
    timerText.text = "-- --";
    string tryAgainString = "Tap the touch pad to try again.";
    if (!winner) { // case A
        winText.text = "Time's up.\n" + tryAgainString;
    }
    if (winner) { // case B
        winText.text = "Well played!\n" + tryAgainString;
    }

}

Post a Comment for "Input Not Recognised From Touchpad"