In this lecture will use our fish class in a game. I've moved our fish pond and fish player controller into a game and I'll show you how the game works first. And then I'll talk about the changes that I needed to make to the fish pond as I included it in the game. So I run the game and I can move my fish back and forth and I can shoot a teddy bear and he died. And then I went back to my original position and I got him too, but I might just shoot for the heck of it and I've missed, but I got him and I got him and so on. So I get to use my ranged weapon and when it kills a teddy bear or goes outside the screen, it comes back to its starting location and then I can keep playing. So let's take a look at the changes I made to the fish pond here in the header file, I added a function called ResetToStartState and it's a private function. Nobody outside the class can call it, but I'm going to use it internally because there are times when I need to make the fish go back to its start state. In the implementation file you can see on begin play. I do all the things I did before and I call that ResetToStartState function which will look at soon. On tech I do the things I did before but I also check to see if I've gone above the top of the screen. So if the Z component of the actor, the pond is above screen, constants, top which I added plus half collision height. That means that the fish is above the top of the screen is totally above the top of the screen and if that's the case, I also reset to start state. I added code here in the on overlap begin function to see if I've just overlapped with the teddy bear. And if the other actor isn't a null pointer and if the other actor has the tag teddy bear because I tagged my teddy bear actors with that game play tag. Then I reset to start state as you saw when I hit a teddy bear, I went back to my start state. This is the same as before. And finally ResetToStartState does a number of different things. First of all I declare a location variable of all zeros and then I changed the Z component to be the bottom plus half collision height. So that puts me right at the very bottom of the screen and I set my location to that location. Remember in the previous lecture I talked about the wasShot flag and I said when you integrate this fish into a game you're going to need to handle wasShot. When does it toggle back to false and here's where toggles back to false. If I'm resetting to my start state for the fish, then I'm going to say I haven't been shot again, right. It's the start state where I haven't been shot. Finally, I need to make sure I stopped the pond and I'll tell you, I didn't realize I needed this in the first place. So let me show you what happens if you don't do this. So when I run my game, I just keep moving even when I go back down to the bottom and by the way you may not have realized this, but I can steer my fish as I drive around. He is steerable even after he shot. So I need to make sure I stop upon as well. And we saw how to do this in the ted the collector game when we were designing our fish pond. We didn't realize that we needed this ResetToStartState function. That was a game specific thing that we needed to do in this particular game and that's okay. It's okay to discover as you use classes that you've designed within games that you don't have the design complete. That's a natural part of the coding process that the implementation feeds, changes to the design and so on. That doesn't mean you did anything wrong it's the nature of this process of development. Okay I did want to talk a little bit about the teddy bears and how they're working as well. So in the teddy bear, teddy bears have health, they have 100 health and they have half collision height as well. And I also included on overlap begin. So in the body of the teddy bear, I save half its collision height. I find the static mash, I set up that begin overlap thing on every frame I'm having the teddy bear moved out. So I'm not using physics on this teddy bear because they don't want the teddy bear to accelerate due to gravity that happens too fast for the gameplay. I want they just steadily fall down the screen. But I do need HalfCollisionHeight so that when the teddy bear falls out the bottom of the screen, I get rid of it. I don't want to keep updating this object as it falls below the screen. I want to destroy it as soon as it's left the screen. In my OnOverlapBegin function I checked to see if I have just overlapped with a fish. Now, you could argue that I could have handled the processing I do here inside the fish on overlap or I could handle resetting the fish to its start state from in here on overlap. But doing overlap processing in both participants in the overlap is reasonable in this case because each of them can be responsible for their own response to the overlap. So we get the other actor the fish and we typecast it to a fishpawn pointer. We make sure it's not null because we need to reduce our health based on the damage the fish inflicts. It turns out that we don't use the fishes setter in this particular game, but we certainly use the getter here. And then finally, if the health is less than or equal to zero, we destroy the teddy bear. So if I come back to the fish header file and I say, well fish only inflict 50 damage, not 100 when I run the game, each teddy bear is going to require two shots to kill it. Whoa! I didn't work very well try again. That's too bad. A new one sort of centered there we go. And there's the second shot for that teddy bear. Like so, so changing the damage inflicted by the fish actually does have an impact. Now I need to hit a teddy bear twice with the fish to actually kill, make this damage 100 again because I like the one shot kills, testing our code one more time. And we're back to one shot kills with our fish. So that's how we can integrate with some changes the fish that we designed into an actual game to recap. In this lecture, we learned that we may need to change our design when we use are unreal engine class and practice, like adding our move to start function in this particular game. We also learned that we may need to implement game specific functionality and functions we already have in our class, like in the OnOverlapBegin function.