Thursday, July 10, 2014

Dev Blog 12 - Short Update

Death counter is now hooked into the final riddle script, so incorrect guesses add to the death count. There's a peculiar issue going on with this however. Initially I thought that this:

    // If any key is pressed, and it isn't the current correct key,
    // increment death count
    if(Input.anyKeyDown && (!Input.GetKeyUp(CorrectKeys[0]))){
        deathCntScript.deathCount++;
    }

would do the trick of increment the death counter when the incorrect keys were pressed. It does, but for some reason also increments the death counter when the correct key is pressed as well. I thought this workaround would achieve the result I wanted:

    // If any key is pressed, if it's the correct key, do nothing.
    // Else, increment death counter.
    if(Input.anyKeyDown){
       if(Input.GetKeyUp (CorrectKeys[0])){
return;
}else{
deathCntScript.deathCount++;
}
    }

But that has the same issue as well. As a temporary fix I'm not decrementing the death counter when the correct key is pressed, to mitigate the false incrementation when the correct key is pressed. I can't tell where this incrementation is coming from or why it's occurs. Maybe because it's in the Update( ) function, return isn't doing anything, but that doesn't explain why the first code example doesn't work.

Working on implementing Final Riddles 2 & 3.

No comments:

Post a Comment