Okay, so let's add some polls functionality. This is actually pretty easy. So if we turn off our in menu UI, and let's turn on our in game UI, you'll see we have a button up here. Play button. And we just need to have an onClick method that we can call that will obviously freeze the position and things like that. So if we get back over to our script, and we've got our public void play button, underneath that we can say, public void polls game.
Then we just need this set of bad boys. And then we just copy this line of code dumped in there as well. And then all we need to do is go over to our pause button. Add a new on click event, Dragon SC manager. done this in the last episode, go to App initialize pools, game pools for Let's play. Game Stop, when we can pause it awesome to set up a play in the game here, and we press polls right here.
But when we actually press play, we're going to run straight into this, this triangle, and we don't actually want that to happen, we want to give our player like, you know, maybe a second to, to, you know, reposition themselves before they get slammed into this triangle. Simple press play now, there's nothing we could do, we would have gone straight into that triangle. So we want to give people a little bit of a warning after they've actually started the game and then pause the game. So how do we do that? Well, let's go back over to our app initialized script, let's create another variable called public. And this one will be a bool.
And we'll just it's just gonna be called has game started. And it's going to equal false. It's going to just default to false. Great. In fact, we can make this private doesn't need to be public just so we keep the inspector neat. Then this is where we do that tricky if statement stuff that I was talking about before.
So inside of our play button, we just want to have an if statement, right? And we want to say, if has game started, equals true? Remember two equals ask the question. Then we want to start couraging. But we want to actually wait for maybe one second. But then we want but if the game hasn't started, well, we want to say, stuck.
We want to say else. So if the game hasn't started, if the if the ball hasn't suddenly equals false, then we want to just start with zero seconds delay. Does that make sense? So if the gamer style equals true, then we wait one second. But if the game hasn't started, we call zero. But we haven't actually set this to true.
So where do we set this to true? Well, you It would make sense to put it inside the pause game method. So, when we pause the game, that's when we say, okay, the game has started now. So first thing we want to do, well probably the second thing we want to do is say how's game started? equals true? Cool.
So let's test it out and see how it works. We press play. And we press play. Everything's going well. It started instantly. Cool.
And then let's press the pause button. And then we'll press the play button. Awesome. So it gives us a one little second amount of time to understand where we've got to go and what we've got to do. Press play, wait one second, bam, back into it. But if we start from the start It just starts.
Awesome. So that is working exactly how we want it to work. And now we have a functioning play button and a functioning pause button. And the next thing we need to do is work on what happens when you run into a triangle. Well, we know what needs to happen. We need to turn on this in Game Over menu UI.
So let's work on that in the next episode.