1 00:00:00,030 --> 00:00:02,130 ‫Welcome to the Project Outline and this video. 2 00:00:02,130 --> 00:00:08,630 ‫I'm going to show you the end result of this chapter and I'm going to tell you how you can build this. 3 00:00:08,640 --> 00:00:10,110 ‫I'm just going to do it real quick. 4 00:00:10,110 --> 00:00:16,500 ‫I don't want to go into too much detail because you should be able to try to build that game yourself. 5 00:00:16,500 --> 00:00:21,270 ‫By now, you have learned most of the things that you need here, and if there is something missing, 6 00:00:21,270 --> 00:00:23,280 ‫then you can of course use the documentation. 7 00:00:23,280 --> 00:00:28,680 ‫Or if you get stuck, you can watch the following videos in which I explain everything step by step. 8 00:00:28,680 --> 00:00:33,480 ‫And if you don't feel like trying it yourself, of course you can go ahead and follow along to videos 9 00:00:33,480 --> 00:00:34,140 ‫anyways. 10 00:00:34,590 --> 00:00:34,980 ‫All right. 11 00:00:34,980 --> 00:00:37,200 ‫So let's have a quick look at what we have here. 12 00:00:37,200 --> 00:00:40,290 ‫So we have multiple different scenes. 13 00:00:40,500 --> 00:00:46,140 ‫We have a game scene, a game over scene, and the main menu and the game scene is the one that we have 14 00:00:46,140 --> 00:00:54,450 ‫open here, which consists of the field, which has all of those components like balls, the racquets, 15 00:00:54,450 --> 00:01:00,930 ‫the two that you can see here, then the ball, and then you have the UI, which is the player, the 16 00:01:00,930 --> 00:01:03,690 ‫number and the other player and his number. 17 00:01:03,690 --> 00:01:08,460 ‫So these are their scores which you also have of course to program. 18 00:01:08,460 --> 00:01:15,810 ‫So whenever the ball moves, the players try to hit the ball and bounce it off to the other direction. 19 00:01:15,810 --> 00:01:17,370 ‫So the ball should bounce off. 20 00:01:17,370 --> 00:01:23,610 ‫And then you try to bring the opponent to a situation where the ball will hit one of the sidewalls. 21 00:01:23,610 --> 00:01:29,430 ‫So if it's the sidewall here on the right hand side, then player one gets a point and if it's the other 22 00:01:29,430 --> 00:01:35,010 ‫side, then play two gets a point and the ball gets faster every time it hits a racket. 23 00:01:35,010 --> 00:01:40,650 ‫So the difficulty goes up and up until it's not possible to hit the ball any more. 24 00:01:40,650 --> 00:01:42,840 ‫So at one point the ball will be too fast. 25 00:01:42,840 --> 00:01:44,910 ‫And I also have set up a maximum speed. 26 00:01:44,910 --> 00:01:50,280 ‫So there will be a speed from which point the ball will not get any faster, but it's still going to 27 00:01:50,280 --> 00:01:53,640 ‫be pretty much impossible to still always hit the ball. 28 00:01:53,640 --> 00:01:56,010 ‫So if the player plays it well, he can beat you. 29 00:01:56,130 --> 00:02:00,690 ‫So the brackets, they have a maximum speed or they have a general speed which is not increased. 30 00:02:00,690 --> 00:02:02,670 ‫So the ball's increase. 31 00:02:02,730 --> 00:02:07,200 ‫Increase speed is going to be a problem at one point and you just can't hit the ball anymore. 32 00:02:07,500 --> 00:02:12,510 ‫Then if you hit the ball at the top side of the racket, the ball will bounce off towards the top. 33 00:02:12,510 --> 00:02:17,190 ‫If you hit it at the bottom side of the racket, it will bounce off towards the bottom. 34 00:02:17,190 --> 00:02:22,110 ‫So that's something where you can trick the enemy into going towards the wrong direction. 35 00:02:22,890 --> 00:02:23,280 ‫All right. 36 00:02:23,280 --> 00:02:25,860 ‫So that's about the basic functionality. 37 00:02:25,890 --> 00:02:28,200 ‫Let's have a quick look how I solve that. 38 00:02:28,200 --> 00:02:30,450 ‫So just so you know how you can do that. 39 00:02:30,450 --> 00:02:35,670 ‫So I created a canvas where I have a label player one and a score player one and the same thing for 40 00:02:35,670 --> 00:02:36,690 ‫the second player. 41 00:02:36,690 --> 00:02:43,260 ‫And I've created scripts, of course, which update the score based on how many points the players have. 42 00:02:43,680 --> 00:02:48,540 ‫Then we have the field which consists of all the elements that are part of the game. 43 00:02:48,540 --> 00:02:55,110 ‫So in terms of the play mechanics, so we have all the walls and we have the rackets and of course the 44 00:02:55,110 --> 00:02:56,880 ‫ball and those middle walls. 45 00:02:56,880 --> 00:03:01,770 ‫I have put them in here because it looks a bit better because that just shows where the center point 46 00:03:01,770 --> 00:03:09,840 ‫is and all of those walls have a 2D box collider so whenever the ball hits one of those, it will bounce 47 00:03:09,840 --> 00:03:14,640 ‫off and the ball itself has a box collider as well. 48 00:03:14,640 --> 00:03:16,980 ‫So it bounces off those walls. 49 00:03:16,980 --> 00:03:20,910 ‫So you know that you have to use a physics material for them. 50 00:03:21,360 --> 00:03:28,080 ‫You have seen those in action and one of the videos then let's have a look at the field a little more. 51 00:03:28,080 --> 00:03:30,150 ‫So you have the four walls, you have the middle walls. 52 00:03:30,150 --> 00:03:32,760 ‫Which are those five walls here? 53 00:03:33,510 --> 00:03:37,410 ‫Then you have the rackets and the records. 54 00:03:37,410 --> 00:03:39,150 ‫As you can see here, we use box colors. 55 00:03:39,150 --> 00:03:40,140 ‫I created the script. 56 00:03:40,140 --> 00:03:41,430 ‫We have the movement speed. 57 00:03:41,460 --> 00:03:45,690 ‫They have a rigid body where I froze rotations and so forth. 58 00:03:45,690 --> 00:03:47,790 ‫So that's something you will have to look into. 59 00:03:47,880 --> 00:03:55,140 ‫And I have the ball here, which has two different sounds, so it plays a specific sound when it hits 60 00:03:55,140 --> 00:03:58,170 ‫the wall and it plays a different sound when it hits a racket. 61 00:03:58,800 --> 00:04:03,000 ‫And of course, it also needs a rigid body and a box collider. 62 00:04:03,000 --> 00:04:07,440 ‫And as you can see here, I have a ball material which bounces off great. 63 00:04:07,440 --> 00:04:10,560 ‫So that's about the game. 64 00:04:10,590 --> 00:04:14,100 ‫And let's have a quick look at how this plays out. 65 00:04:15,190 --> 00:04:18,140 ‫So this the sound played on awake. 66 00:04:18,160 --> 00:04:21,010 ‫I set that up just to see if sounds are working. 67 00:04:21,580 --> 00:04:26,740 ‫And then as you can see, if it bounce it, if it bounces on the left hand side, it bounces off correctly. 68 00:04:26,920 --> 00:04:28,630 ‫So it bounces towards the top. 69 00:04:28,630 --> 00:04:30,010 ‫And there you are. 70 00:04:30,130 --> 00:04:33,610 ‫I made a point or I got one point. 71 00:04:33,610 --> 00:04:35,210 ‫So now I'm just going to lose. 72 00:04:35,210 --> 00:04:42,340 ‫I'm just going to move out of the way and lose the game because at five points I will move over to the 73 00:04:42,340 --> 00:04:45,040 ‫game over scene and in the game over scene. 74 00:04:45,040 --> 00:04:50,110 ‫I have a very simple text which says Game over and a replay button. 75 00:04:50,260 --> 00:04:52,320 ‫So that we are game over and replay. 76 00:04:52,330 --> 00:04:58,120 ‫And if I hit the replay button, I go back to the game and I have zero zero again and I start a completely 77 00:04:58,120 --> 00:04:58,870 ‫new round. 78 00:04:59,090 --> 00:05:03,430 ‫As you can see, I have an AI here, so the right racket is moving. 79 00:05:04,300 --> 00:05:06,430 ‫Even if I don't do anything. 80 00:05:07,240 --> 00:05:13,740 ‫So the left one is run by user input, which in my case is W and S or the arrow keys. 81 00:05:13,750 --> 00:05:19,680 ‫And that one here is simply an AI which tries to follow along the position of the ball. 82 00:05:19,690 --> 00:05:22,480 ‫So that's what you should try to implement. 83 00:05:23,050 --> 00:05:25,510 ‫And then we have our main menu. 84 00:05:25,510 --> 00:05:29,560 ‫And from that main menu you can go into the game scene as well. 85 00:05:29,560 --> 00:05:35,200 ‫So you have Pong as the title and whenever you hit play you go back into the game. 86 00:05:36,950 --> 00:05:39,110 ‫And that's the game scene, of course. 87 00:05:39,110 --> 00:05:42,790 ‫So in the game scene, there's one thing that I haven't explained yet. 88 00:05:42,800 --> 00:05:49,970 ‫The ball, it bounces off the rackets, but in my case I have implemented the functionality which makes 89 00:05:49,970 --> 00:05:51,800 ‫the ball move without physics. 90 00:05:51,800 --> 00:05:52,880 ‫So it bounces off. 91 00:05:52,880 --> 00:05:59,900 ‫And then regarding the ball, I have used velocity here so I don't add a force to the ball, but I simply 92 00:05:59,900 --> 00:06:02,960 ‫use the velocity functionality of the rigid body. 93 00:06:02,960 --> 00:06:08,450 ‫So I change the velocity based on bounces for example, and it has a specific velocity at the beginning 94 00:06:08,450 --> 00:06:12,080 ‫and then if it bounces off, the velocity goes towards the other direction. 95 00:06:12,080 --> 00:06:17,030 ‫So when it bounces off the left racquet, the ball will go towards the right, and if it bounces off 96 00:06:17,030 --> 00:06:19,160 ‫the right racquet, it will go towards the left. 97 00:06:19,220 --> 00:06:19,880 ‫All right. 98 00:06:19,880 --> 00:06:22,280 ‫So that should be pretty much it. 99 00:06:22,280 --> 00:06:27,710 ‫As I said, I highly recommend you to try this on your own because you will learn a lot more trying 100 00:06:27,710 --> 00:06:33,500 ‫to build this game yourself than just following along the videos or even just watching the videos without 101 00:06:33,500 --> 00:06:36,260 ‫trying it in parallel. 102 00:06:36,470 --> 00:06:41,150 ‫So go ahead and please let me know if that challenge was too difficult. 103 00:06:41,150 --> 00:06:46,520 ‫If you think that there was some functionality missing that you couldn't find in the documentation or 104 00:06:46,520 --> 00:06:51,800 ‫that you couldn't find online where you say, okay, this video is really necessary for me to understand 105 00:06:51,800 --> 00:06:53,480 ‫what's going on and so forth. 106 00:06:53,480 --> 00:06:58,340 ‫Then I can add something, of course, but otherwise you should be able to do that. 107 00:06:58,340 --> 00:07:03,980 ‫And if even if something is missing, then it's even better if you find it out on your own because that 108 00:07:03,980 --> 00:07:10,280 ‫will teach you to find functionality and find answers to your questions on your own. 109 00:07:10,280 --> 00:07:14,870 ‫And that's something that you will definitely need whenever you want to go ahead and build your own 110 00:07:14,870 --> 00:07:16,160 ‫projects in the future. 111 00:07:16,910 --> 00:07:17,360 ‫All right. 112 00:07:17,360 --> 00:07:24,920 ‫So please go ahead and build that or follow along the videos and see you in the next videos or the next 113 00:07:24,920 --> 00:07:25,490 ‫chapter.