Last time we re-factored our mouse button processing to use a named access that we set up in the input manager. But we're not quite getting the behavior we want. The problem is we need to only process that input on the first frame on which that input is provided. That's what we'll learn how to do in this lecture. So here's how our game currently works. If I click the left mouse button. I get a number of different characters. In fact, I can hold down the left mouse button and toggle through bunches of different characters and that's not what we want. We want to change the character on the first frame in which the player has pressed the left mouse button. Our modifications will be in the character changer script. The way we'll do this is we'll use a flag to keep track of whether we had input on the change character input axis on the previous frame in the game. I'll need a field to do that, and my comment will say this is for first frame input support. I call this a flag which should have implied to you that this will be a blue variable. We just need it to be true or false. You may be tempted to use a really short name here, assuming you'll remember what it meant, six months or a year from now, but let's not, let's give it a long name that's very descriptive, so previous change character input. That tells us exactly what it is. Did we have previous change character input? I'll initialize it to false, because when the game starts running, we don't have any change character input provided. The rest of our work will be in the update method. The first thing we'll do is we'll make sure that if we don't have change character input, that we set that flag to false, no matter what it was before, if we don't have input on the change character axis then that flag should be set to false. We down here, we need to add an else clause. You can tell that we're on the right close curly brace, because the corresponding opening curly brace is highlighted just like this close curly braces. So I'll say else, and because we're a long way away from the Boolean expression we checked, I'll add a comment here that says no change character input. I know it seems strange to comment a single line of code here, but we're a long way away from the Boolean expression. So this helps our readability to know what we're actually doing in this else clause. Previous change character input should be false here. The next thing we do is up here, because we know we don't automatically want to do this processing here, we know we have input on the change character axis, but we don't yet know if this is the first frame that we have input on that axis, so we'll check. We'll say, if not previous change character input and I'll add the closed curly brace as well. This Boolean expression might look strange to you. You might think we should say if previous change character input equal equal false and that would be a valid Boolean expression that would even check this condition. But if previous change character input is in fact false, then not previous change character input is true. So this is another way to check that Boolean expression. I personally prefer doing it this way rather than using the equal, equal false structure for my Boolean expression. The first thing I need to do here, I need to add a line of code that is exactly as suggested to say that I am now processing the first input frame of this change character input axis. So now I'm saying, yes, I do have previous changed character input. It's important to realize that both this assignment here and this assignment down here, is really saving this information for later frames, for later calls to the update method. When I set this to true here and change the character, as you can see down below, the next time I come into the update method, if I'm still holding the left mouse button down, even if I'm clicking it as quickly as I can, even if I have input on that input axis, previous changed character input is now true, so not true is false. I won't do any of this work inside, and I won't do any of this work inside until I have a frame where the left mouse button isn't down. When that happens, I set that flag to false, and it will keep getting set to false until I provide input on the left mouse button again and go through this process again. We're using previous change character input to keep track from one call to the update method to a later call on the update method, whether or not we had changed character input on the previous frame. That's why we need a field for this, not a local variable here in the update method, because we have to save its value from one call to the update method to a later call. Let's go ahead and build. Back in the editor when I run the game, you'll see each click it gives me new character as long as the random number generator doesn't give us the same character again. But I'm holding the left mouse button down here and you can see I only had one character change and it won't change characters again until I release the left mouse button and then I can press it again to get another change character. So that's how we can make sure we only process the first frame of input on a particular input axis. To recap, in this lecture, you learned how we can process only the first frame of input provided on a particular named axis. This is a really powerful idea that applies to any input device we decide to use.