vendredi 4 décembre 2015

if function loop: initialized variable isn't used

// Update is called once per frame
void Update () {
        if (Input.GetKeyDown(KeyCode.UpArrow)){
            //print("Up arrow was pressed");
            min = guess;
            guess = (max + min)/2;
            print ("Higher or lower than " + guess);

I initialized and declared instance variable min as 1 and guess as 500. After up arrow is pressed, the console asks the user to press up or down arrow to narrow down the answer. When the user presses up, the if statement is activated. However, the console doesn't use the instance variable guess. It uses the guess variable within the update function. I dont know if I'm making sense. I would like to know the logic behind why the computer dont use the instance variable.

Thank you.

Aucun commentaire:

Enregistrer un commentaire