1 00:00:00,090 --> 00:00:00,870 ‫We'll come back. 2 00:00:00,870 --> 00:00:04,470 ‫And this video, we are going to add the game over scene to our game. 3 00:00:04,470 --> 00:00:08,850 ‫So let's simply reproduce this main menu or duplicate it. 4 00:00:08,850 --> 00:00:15,210 ‫So copy and paste in windows and duplicate with Command D in Macintosh. 5 00:00:15,300 --> 00:00:23,310 ‫So let's change the name from main menu to game over and now let's open up the scene. 6 00:00:23,310 --> 00:00:27,990 ‫So instead of Pong, we want to have game over here as a text. 7 00:00:27,990 --> 00:00:29,460 ‫So let's change that. 8 00:00:30,690 --> 00:00:35,970 ‫Let's change the title from Pong to game over. 9 00:00:37,650 --> 00:00:39,810 ‫And now of course, the size is not enough anymore. 10 00:00:39,810 --> 00:00:45,030 ‫So let's change the width to 700 and center the text. 11 00:00:45,450 --> 00:00:46,770 ‫It's centered, it's good. 12 00:00:46,770 --> 00:00:49,110 ‫And now we can replace it a little bit. 13 00:00:49,110 --> 00:00:53,070 ‫So let's replace that component to the center. 14 00:00:53,070 --> 00:00:57,810 ‫And instead of play we can say something like replay. 15 00:00:58,260 --> 00:01:00,900 ‫So here we simply say replay. 16 00:01:01,140 --> 00:01:04,740 ‫And now let's have a look at the button functionality. 17 00:01:04,740 --> 00:01:09,390 ‫It says Play game and that's the script here, play button, play game. 18 00:01:09,390 --> 00:01:15,570 ‫Let's have a look at the script once again, what it does just to make sure that it simply moves over 19 00:01:15,570 --> 00:01:21,360 ‫to the other scene and then we can simply reproduce that or re-use that. 20 00:01:21,450 --> 00:01:21,930 ‫All right. 21 00:01:21,930 --> 00:01:22,620 ‫That's perfect. 22 00:01:22,620 --> 00:01:24,870 ‫It says scene manager load scene game. 23 00:01:24,870 --> 00:01:26,430 ‫That's exactly what we want. 24 00:01:26,550 --> 00:01:27,060 ‫All right. 25 00:01:27,060 --> 00:01:35,670 ‫So what we need to do, however, is to find a way to get from our game scene to this game over scene. 26 00:01:35,670 --> 00:01:42,180 ‫So, first of all, let's save the scene with command s or control as or with file save scenes. 27 00:01:42,420 --> 00:01:47,790 ‫And then let's go to our main menu, then let's go to our game. 28 00:01:48,570 --> 00:01:53,070 ‫And actually we need to open the script that controls the score. 29 00:01:53,070 --> 00:01:55,110 ‫So let's open up score controller. 30 00:01:55,290 --> 00:01:59,640 ‫And then here we have this debug log that says Game one. 31 00:01:59,640 --> 00:02:06,210 ‫And in here we want to move from this scene to or from the game scene to the game over scene. 32 00:02:06,210 --> 00:02:12,570 ‫So using unity engine, that scene management. 33 00:02:13,020 --> 00:02:20,970 ‫So we need to have this namespace again because in scene management we will find the scene manager, 34 00:02:20,970 --> 00:02:24,600 ‫so scene manager and then we want to load a scene. 35 00:02:24,600 --> 00:02:32,280 ‫So let's enter load scene and here we enter the scene name and it's just game over. 36 00:02:32,310 --> 00:02:35,700 ‫Let's save that and let's give it a try first. 37 00:02:35,700 --> 00:02:38,490 ‫So let's test it actually. 38 00:02:38,490 --> 00:02:45,900 ‫Let's change the condition to win the game because currently it's a lot higher. 39 00:02:45,930 --> 00:02:49,080 ‫So let's change this goal to win to let's say one. 40 00:02:49,080 --> 00:02:52,890 ‫So let's have a quick try to see if that works out. 41 00:02:52,890 --> 00:02:59,790 ‫So let's not move at all and see if we get to the next scene and there you are. 42 00:02:59,820 --> 00:03:01,110 ‫Nothing happens. 43 00:03:01,110 --> 00:03:07,590 ‫And if we look at the error, it says Scene game over, could not be loaded because it has not been 44 00:03:07,590 --> 00:03:08,940 ‫added to the build settings. 45 00:03:09,060 --> 00:03:09,450 ‫All right. 46 00:03:09,450 --> 00:03:11,070 ‫We have had that error before. 47 00:03:11,070 --> 00:03:16,260 ‫And if you want to make sure that game over works, you have to add the scene. 48 00:03:16,260 --> 00:03:19,710 ‫So let's go to a project in the background to the assets. 49 00:03:19,710 --> 00:03:27,480 ‫And here let's go to game over and add this scene to your scenes and build. 50 00:03:28,340 --> 00:03:28,690 ‫Okay. 51 00:03:28,700 --> 00:03:30,110 ‫Now we can try it again. 52 00:03:31,940 --> 00:03:36,290 ‫And that error should disappear and we should move from this scene to the next scene. 53 00:03:36,470 --> 00:03:37,670 ‫So let's have a look. 54 00:03:38,980 --> 00:03:43,660 ‫And we see game over now we can replay and we get back to the game. 55 00:03:47,570 --> 00:03:48,800 ‫If you want to show. 56 00:03:49,460 --> 00:03:50,510 ‫Let's say that real quick. 57 00:03:51,830 --> 00:03:52,220 ‫All right. 58 00:03:52,220 --> 00:03:54,680 ‫So now you have seen how you can create a game over. 59 00:03:54,920 --> 00:04:01,970 ‫Real quickly, if you want to show which player has won, you can use player press or you could use, 60 00:04:01,970 --> 00:04:04,310 ‫for example, don't destroy a load. 61 00:04:04,310 --> 00:04:08,540 ‫So static variables, we're going to do that in one of the later projects. 62 00:04:08,540 --> 00:04:13,970 ‫I wanted to keep this project real simple because you have already learned plenty of concepts in this 63 00:04:13,970 --> 00:04:14,480 ‫game. 64 00:04:14,480 --> 00:04:20,180 ‫You can, however, come back later on and apply those new concepts that you will learn in further chapters 65 00:04:20,180 --> 00:04:21,290 ‫to this game. 66 00:04:21,860 --> 00:04:22,250 ‫Great. 67 00:04:22,250 --> 00:04:23,750 ‫So see you in the next video.