1 00:00:04,680 --> 00:00:12,330 ‫If we have a look at the UI of fruit ninja, we can see that we have a well, a score, a best score, 2 00:00:12,330 --> 00:00:14,220 ‫and then we have a timer that runs up. 3 00:00:14,220 --> 00:00:17,700 ‫And that's what we need to add to our game as well, of course. 4 00:00:17,700 --> 00:00:23,760 ‫So let's go ahead and create a new object first and call it game manager. 5 00:00:25,830 --> 00:00:27,930 ‫And in here we add a script. 6 00:00:27,930 --> 00:00:35,190 ‫So let's create a new script and call that, and we assign a new script to that game manager. 7 00:00:35,190 --> 00:00:41,010 ‫So let's create a new script here in our scripts folder and call that game manager. 8 00:00:41,910 --> 00:00:45,780 ‫Now let's drag the game manager into our game manager script. 9 00:00:47,010 --> 00:00:51,600 ‫Now let's direct the game manager script to our game manager and edit that. 10 00:00:53,520 --> 00:00:57,960 ‫Now what our game manager will do for now is count the score. 11 00:00:57,960 --> 00:01:02,580 ‫So let's create a method and several variables for that. 12 00:01:02,610 --> 00:01:09,330 ‫First of all, we will need an integer which will have the score value assigned to it, and then we 13 00:01:09,330 --> 00:01:11,400 ‫will need a text object. 14 00:01:11,400 --> 00:01:19,380 ‫And in order to work with text we need to add unity engine start UI. 15 00:01:19,980 --> 00:01:22,050 ‫So the namespace, the unity engine, the UI. 16 00:01:22,080 --> 00:01:32,280 ‫Now we can access the text, class, public text and we're going to call that score text and let's create 17 00:01:32,280 --> 00:01:35,280 ‫a method which will simply increase our score. 18 00:01:35,280 --> 00:01:46,770 ‫So public void, increase score, and now let's increase the score by, let's say two each time that 19 00:01:46,770 --> 00:01:51,090 ‫somebody calls this method or any class calls this method. 20 00:01:52,440 --> 00:01:54,330 ‫So increase by two. 21 00:01:55,500 --> 00:01:57,960 ‫And then also we want to set the score text. 22 00:01:57,960 --> 00:02:03,060 ‫So each time the score is increased, we want to update the text variable, of course, as well. 23 00:02:03,060 --> 00:02:05,520 ‫So score to string. 24 00:02:09,120 --> 00:02:13,950 ‫All right, now let's save that script and let's go back to Unity in here. 25 00:02:13,950 --> 00:02:18,930 ‫We will create a new object and I'm going to call that UI. 26 00:02:19,830 --> 00:02:21,750 ‫So let's change the name of the game object. 27 00:02:21,750 --> 00:02:22,890 ‫Let's call it UI. 28 00:02:22,890 --> 00:02:31,200 ‫And now let's add a UI text here that will create the canvas and I'm going to drag the canvas into the 29 00:02:31,200 --> 00:02:32,610 ‫UI game object. 30 00:02:33,180 --> 00:02:40,200 ‫And what I want to use here is that our canvas scalar doesn't have a constant pixel size, but that 31 00:02:40,200 --> 00:02:42,270 ‫it scales with the screen size. 32 00:02:42,450 --> 00:02:51,030 ‫And we can set the resolution to, for example, 800 times 800 or 19, 20 times 1080, whatever you 33 00:02:51,030 --> 00:02:51,960 ‫want to have. 34 00:02:52,230 --> 00:02:55,320 ‫So for now, we will just have the text in there. 35 00:02:55,320 --> 00:03:03,330 ‫So let's a look what this looks like currently and we don't see the text even so let's manage that. 36 00:03:04,350 --> 00:03:05,430 ‫Let's go to our canvas. 37 00:03:05,430 --> 00:03:06,030 ‫There you are. 38 00:03:06,030 --> 00:03:10,110 ‫And you see that our text is currently not even inside of our game. 39 00:03:10,110 --> 00:03:18,510 ‫Let's see, our UI element should be reset and now we can change the position of our text. 40 00:03:18,750 --> 00:03:22,110 ‫I want my score text to be at the top left side of my UI. 41 00:03:22,110 --> 00:03:27,690 ‫So let's zoom in a little bit and let's change the rect transform to the top left. 42 00:03:27,690 --> 00:03:29,340 ‫That will be the anchor preset. 43 00:03:29,700 --> 00:03:35,160 ‫So that means from this perspective on the values of X and Y are calculated. 44 00:03:35,160 --> 00:03:37,110 ‫So let's just choose zero zero. 45 00:03:37,110 --> 00:03:41,640 ‫And you can see that our text now is at this top left corner. 46 00:03:42,180 --> 00:03:47,730 ‫Now, good values would be, for example, 100 and -75. 47 00:03:48,600 --> 00:03:53,100 ‫And maybe let's change the size of our text as well. 48 00:03:53,100 --> 00:03:54,690 ‫So this will be the score text. 49 00:03:54,690 --> 00:04:04,050 ‫So let's maybe enter a value like zero in here and change the name of it. 50 00:04:04,050 --> 00:04:06,300 ‫So I'm going to call it score text. 51 00:04:07,350 --> 00:04:11,340 ‫Now, of course, the font size is a little bit too small, so let's change that. 52 00:04:11,400 --> 00:04:14,760 ‫Let's go with, let's say 120. 53 00:04:15,180 --> 00:04:16,740 ‫And as you can see now, it disappears. 54 00:04:16,740 --> 00:04:18,510 ‫So we don't see the number anymore. 55 00:04:18,510 --> 00:04:21,180 ‫And that has to do with the overflow. 56 00:04:21,180 --> 00:04:28,860 ‫So if you add horizontal and vertical overflow, what that will do is it will show the number no matter 57 00:04:28,860 --> 00:04:29,340 ‫what. 58 00:04:30,150 --> 00:04:35,550 ‫Now, no matter what the size here, for example, for the width and height is for this object. 59 00:04:36,840 --> 00:04:39,210 ‫So that's how it will currently look like. 60 00:04:39,210 --> 00:04:42,810 ‫Maybe it's not the perfect position to play around with it. 61 00:04:42,810 --> 00:04:45,240 ‫Maybe so let's drag it up there. 62 00:04:46,050 --> 00:04:50,820 ‫So the wide position of zero, I think that should be around. 63 00:04:50,820 --> 00:04:51,510 ‫Fine. 64 00:04:51,510 --> 00:04:53,970 ‫Now let's change the color of the text. 65 00:04:54,300 --> 00:04:58,860 ‫Let's make it an orange ish or orange ish color. 66 00:05:01,060 --> 00:05:01,930 ‫Like that. 67 00:05:02,770 --> 00:05:03,570 ‫Now let's see. 68 00:05:03,580 --> 00:05:04,750 ‫There is zero. 69 00:05:04,780 --> 00:05:07,270 ‫Of course, our background doesn't look as nice anymore. 70 00:05:07,300 --> 00:05:10,600 ‫We need to change the background of our game. 71 00:05:12,460 --> 00:05:14,410 ‫But at least we have our score text. 72 00:05:14,410 --> 00:05:20,680 ‫So now let's duplicate that text and call this one high score text. 73 00:05:22,180 --> 00:05:24,750 ‫And now let's change that high score text. 74 00:05:24,760 --> 00:05:30,500 ‫Let's drag it to the bottom and let's enter best colon zero. 75 00:05:30,520 --> 00:05:33,040 ‫And as you can see, this is, of course, way too big. 76 00:05:33,040 --> 00:05:38,230 ‫So let's scale that down to maybe 36. 77 00:05:40,980 --> 00:05:42,270 ‫That looks much better. 78 00:05:42,380 --> 00:05:44,860 ‫So look in the game best zero. 79 00:05:45,020 --> 00:05:50,790 ‫Okay, for now, let's maybe change the background of our main camera. 80 00:05:50,790 --> 00:05:51,690 ‫So now it's. 81 00:05:52,920 --> 00:06:00,090 ‫This color, this orange brownish color, and maybe this will look better now. 82 00:06:00,090 --> 00:06:00,630 ‫It's fine. 83 00:06:00,630 --> 00:06:02,190 ‫I think that's better for now. 84 00:06:02,820 --> 00:06:09,060 ‫Now, in order to make our number look a little bit cooler, what we can do is add an outline so you 85 00:06:09,060 --> 00:06:11,070 ‫can go here to UI. 86 00:06:11,400 --> 00:06:19,920 ‫So add component, then UI effects and then you'll find outline here that will do is it will add an 87 00:06:19,920 --> 00:06:26,310 ‫outline to your game so you could or to you to your text and you could do that like this. 88 00:06:26,310 --> 00:06:34,170 ‫As you can see now you can create an edge, an outline edge to your score text, your high score text. 89 00:06:34,170 --> 00:06:41,070 ‫Here, the white one would make sense if the main camera, for example, would be a bright color, then 90 00:06:41,070 --> 00:06:42,900 ‫a black one would look better. 91 00:06:43,410 --> 00:06:49,920 ‫So if it's like this color, for example, then maybe the score should have an effect. 92 00:06:49,920 --> 00:06:51,510 ‫Color of black. 93 00:06:52,300 --> 00:06:57,520 ‫So I think that looks much better than the high score text should get one as well. 94 00:06:57,520 --> 00:07:02,980 ‫So let's add in UI effects outline. 95 00:07:04,150 --> 00:07:06,760 ‫And as you can see now, they look much better. 96 00:07:07,600 --> 00:07:12,340 ‫All right, so now let's implement our score text in our code. 97 00:07:12,340 --> 00:07:19,300 ‫So our game manager already expects a score text so we can drag that in there and our current score 98 00:07:19,300 --> 00:07:20,200 ‫will be zero. 99 00:07:20,200 --> 00:07:23,680 ‫So if we set that to five, for example, let's have a look what happens. 100 00:07:25,350 --> 00:07:27,690 ‫Actually, let's set that to five endgame. 101 00:07:28,230 --> 00:07:30,000 ‫As you can see, nothing happens yet. 102 00:07:30,000 --> 00:07:33,180 ‫So we will need to add score. 103 00:07:33,180 --> 00:07:41,880 ‫So which means we will need to call this method here, this increased score method in our fruit script. 104 00:07:41,880 --> 00:07:48,540 ‫So whenever we create a sliced fruit, that means we had a we got an additional score. 105 00:07:48,960 --> 00:07:54,150 ‫So in order to do that, let's add find object of type 106 00:07:57,060 --> 00:08:02,190 ‫game manager and increase the score. 107 00:08:02,760 --> 00:08:07,860 ‫So this will now increase the score every time that we slice a fruit. 108 00:08:09,090 --> 00:08:09,450 ‫All right. 109 00:08:09,450 --> 00:08:10,620 ‫So now let's test it. 110 00:08:10,710 --> 00:08:11,790 ‫Let's start the game. 111 00:08:13,880 --> 00:08:17,030 ‫And let's slice through our fruits. 112 00:08:17,030 --> 00:08:20,630 ‫And as you can see, our score is increased by two every time. 113 00:08:21,290 --> 00:08:27,590 ‫And maybe we want to have different values based on the fruit that we have sliced currently only slice 114 00:08:27,620 --> 00:08:31,130 ‫oranges, but maybe we want to slice other objects as well. 115 00:08:31,160 --> 00:08:34,460 ‫Then we would also want to have different values, for example. 116 00:08:34,460 --> 00:08:37,340 ‫So currently let's just assign three here. 117 00:08:37,370 --> 00:08:43,070 ‫Now of course, we will get an error because the game manager itself doesn't know what these three should 118 00:08:43,070 --> 00:08:43,450 ‫do. 119 00:08:43,460 --> 00:08:53,840 ‫So let's add an int points in here and now instead of saying score plus two plus equal to, we just 120 00:08:53,840 --> 00:08:57,260 ‫increase it by whatever points is delivered. 121 00:08:57,350 --> 00:09:00,710 ‫So in our case now it will be three. 122 00:09:00,710 --> 00:09:04,940 ‫So every time we run or we slice a fruit, we will get three points now. 123 00:09:04,940 --> 00:09:07,810 ‫So let's check that out real quick, if that's true. 124 00:09:07,820 --> 00:09:08,660 ‫So. 125 00:09:09,720 --> 00:09:11,610 ‫Let's slice a fruit. 126 00:09:11,610 --> 00:09:12,450 ‫And there we are. 127 00:09:12,450 --> 00:09:14,280 ‫We get three points. 128 00:09:15,360 --> 00:09:15,780 ‫All right. 129 00:09:15,780 --> 00:09:22,440 ‫Now, next, we need to add a functionality that stops the game because now we can play the game endlessly 130 00:09:22,440 --> 00:09:26,130 ‫and will constantly get points and there is no punishment for any behavior. 131 00:09:26,130 --> 00:09:29,160 ‫And of course, we want to change that in fruit ninja. 132 00:09:29,160 --> 00:09:31,530 ‫That's usually done by the bomb or by the timer. 133 00:09:31,530 --> 00:09:33,750 ‫So if the timer runs up, the game will be stopped. 134 00:09:33,750 --> 00:09:36,630 ‫Or if we hit a bomb, then the timer stops as well. 135 00:09:36,630 --> 00:09:39,330 ‫So let's add the bomb to our game. 136 00:09:39,330 --> 00:09:40,950 ‫So let's go to the scene view. 137 00:09:40,980 --> 00:09:44,280 ‫Let's open our models folder. 138 00:09:44,280 --> 00:09:45,540 ‫And here we had the bomb. 139 00:09:45,540 --> 00:09:49,620 ‫All right, so now let's go into a scene view and let's drag the bomb into our game. 140 00:09:49,620 --> 00:09:52,320 ‫Well, actually, it's too big, so let's get rid of it again. 141 00:09:52,320 --> 00:09:56,100 ‫So let's delete the bomb and go to our bomb model. 142 00:09:56,100 --> 00:10:00,330 ‫Now let's change the scale factor to 0.3 and apply that. 143 00:10:00,540 --> 00:10:02,250 ‫And now we can drag the bomb in. 144 00:10:02,250 --> 00:10:04,260 ‫And I think that size is much better. 145 00:10:04,260 --> 00:10:06,480 ‫So now let's add some components to it. 146 00:10:06,480 --> 00:10:15,210 ‫For example, a physics 2D, rigid body and a physics to DX box or actually circle collider. 147 00:10:15,210 --> 00:10:17,280 ‫Here, this should be fine. 148 00:10:17,280 --> 00:10:19,950 ‫All right, the circle collider fits well, I think. 149 00:10:21,990 --> 00:10:24,780 ‫All right, so what do we want to happen if we hit a bump? 150 00:10:24,780 --> 00:10:30,210 ‫Well, we want to pause the game and show the game over screen or something like that. 151 00:10:30,210 --> 00:10:33,540 ‫So let's add a script to our bomb. 152 00:10:34,410 --> 00:10:40,770 ‫So I'm going to add a new script and I'm going to call that one bomb script or actually just bomb. 153 00:10:41,040 --> 00:10:44,490 ‫And now let's open that bomb script up in here. 154 00:10:44,490 --> 00:10:51,180 ‫We will add an on trigger enter to DX method. 155 00:10:51,180 --> 00:10:56,970 ‫So whenever we hit the bomb, we want to see if the blade hit us. 156 00:10:56,970 --> 00:10:59,670 ‫So blade b equals collision 157 00:11:01,890 --> 00:11:02,700 ‫dot. 158 00:11:02,790 --> 00:11:12,510 ‫Actually, it's not this collision, it's that collision here collision dot get component and blade. 159 00:11:12,510 --> 00:11:18,750 ‫So what that means, well, we've seen that code already, but what that means if the object that was 160 00:11:18,750 --> 00:11:23,400 ‫triggered or hit triggered us, if that's the blade, then do something. 161 00:11:23,400 --> 00:11:26,040 ‫And if it's not the blade, then return. 162 00:11:26,040 --> 00:11:36,690 ‫So if not B return, but if it is B, then we want to find object of type game manager. 163 00:11:36,690 --> 00:11:40,470 ‫So then we want to access our game manager and call a method from him. 164 00:11:40,470 --> 00:11:43,080 ‫So let's say on bomb hit. 165 00:11:43,080 --> 00:11:48,960 ‫So whenever we hit the bump now it complains that there is no method called on bomb hit and we'll find 166 00:11:48,960 --> 00:11:54,330 ‫that method in our game manager or we need to create that method and the game manager. 167 00:11:54,330 --> 00:12:03,720 ‫So let's create that method void on bomb hit and that should be public so that we can access it from 168 00:12:03,720 --> 00:12:04,170 ‫outside. 169 00:12:04,170 --> 00:12:08,520 ‫Of course, for now, let's just say bump was hit. 170 00:12:08,520 --> 00:12:13,740 ‫So debug log bomb hit. 171 00:12:18,200 --> 00:12:19,550 ‫So let's save that script. 172 00:12:19,550 --> 00:12:21,380 ‫Let's save the bomb script as well. 173 00:12:21,380 --> 00:12:24,680 ‫Now we see the error is not there anymore. 174 00:12:26,440 --> 00:12:27,410 ‫Now let's test that. 175 00:12:27,410 --> 00:12:28,580 ‫So let's go back. 176 00:12:29,750 --> 00:12:33,950 ‫Actually, let's drag the bomb script into our script folder while we're added. 177 00:12:33,950 --> 00:12:38,900 ‫And now let's run the game and let's see if I hit a bomb. 178 00:12:39,140 --> 00:12:46,130 ‫Actually, the bomb was moving too fast, so I'm going to push it to the top so I can actually what 179 00:12:46,130 --> 00:12:49,370 ‫I can do is for now, deactivate the. 180 00:12:50,960 --> 00:12:51,920 ‫Gravity. 181 00:12:52,670 --> 00:12:55,160 ‫So let's say gravity scale zero. 182 00:12:57,800 --> 00:12:59,330 ‫And let's see what happens. 183 00:13:01,270 --> 00:13:05,530 ‫And I can drag or hit the bomb. 184 00:13:05,560 --> 00:13:11,110 ‫Actually, nothing will happen, of course, as our trigger as there is no trigger in the circle collider. 185 00:13:11,140 --> 00:13:14,200 ‫Now let's see once again what happens now. 186 00:13:15,730 --> 00:13:20,380 ‫And as you can see, Bob hit is called Every Time that I Go Through the bomb. 187 00:13:20,410 --> 00:13:20,830 ‫All right. 188 00:13:20,830 --> 00:13:24,040 ‫So now we can change the gravity scale to one again. 189 00:13:24,340 --> 00:13:26,230 ‫That was just for testing purposes. 190 00:13:27,400 --> 00:13:29,590 ‫And now our bomb should work. 191 00:13:29,620 --> 00:13:32,290 ‫Now, what we want to do is we want to. 192 00:13:33,690 --> 00:13:36,120 ‫Stop the game whenever that happens. 193 00:13:36,450 --> 00:13:43,230 ‫So we can just say time dot time scale is equal to zero. 194 00:13:43,470 --> 00:13:45,270 ‫That will just stop the game. 195 00:13:47,230 --> 00:13:54,670 ‫So this time, the time scale is in general a functionality that allows you to reduce the speed of your 196 00:13:54,670 --> 00:13:55,180 ‫game. 197 00:13:55,180 --> 00:14:00,010 ‫So zero means there is no speed at all, which means there is no movement and you stop the game. 198 00:14:00,010 --> 00:14:02,340 ‫And one would be you have the normal speed. 199 00:14:02,350 --> 00:14:08,110 ‫So timescale one is the default value and timescale zero is, for example, to stop the game. 200 00:14:08,110 --> 00:14:15,070 ‫So let's save that script and check that out again and let's see if I can hit the bomb quickly enough. 201 00:14:16,100 --> 00:14:17,660 ‫In order to stop the game. 202 00:14:18,170 --> 00:14:24,230 ‫And as you can see, I dashed through it and my bombs were actually my fruits stopped and the bomb stopped 203 00:14:24,230 --> 00:14:24,800 ‫as well. 204 00:14:26,970 --> 00:14:29,280 ‫All right, now we only have one bump. 205 00:14:29,280 --> 00:14:34,350 ‫So this one bump is fine, but we want to randomly spawn bombs as well. 206 00:14:34,410 --> 00:14:38,820 ‫And in order to do that, we need to go back to our sponsor game object. 207 00:14:38,820 --> 00:14:40,400 ‫So our script better set. 208 00:14:40,410 --> 00:14:42,420 ‫So let's go to the sponsor script. 209 00:14:43,970 --> 00:14:51,260 ‫And currently we only have one fruit to spawn, so we can only spawn one type of fruit. 210 00:14:51,270 --> 00:14:58,250 ‫In this case, it's an orange, but what we want to have is to be able to spawn oranges, spawn bananas, 211 00:14:58,250 --> 00:15:02,210 ‫spawn whatever we think of, and also spawn bombs. 212 00:15:02,210 --> 00:15:10,460 ‫And in order to do that, we need to change this fruit to spawn to an array, which is an array of game 213 00:15:10,460 --> 00:15:10,940 ‫objects. 214 00:15:10,940 --> 00:15:19,190 ‫So let's add the square brackets and let's change that to objects to spawn, because it's not just fruits, 215 00:15:19,190 --> 00:15:20,810 ‫it's objects in general. 216 00:15:20,840 --> 00:15:27,110 ‫Now, of course, here we get an error because we try to spawn one simple fruit and this method is not 217 00:15:27,110 --> 00:15:28,130 ‫available anymore. 218 00:15:28,130 --> 00:15:35,660 ‫So what we need to do is we need to randomly create a game object, which is either a bump or which 219 00:15:35,660 --> 00:15:36,950 ‫is another fruit. 220 00:15:36,950 --> 00:15:39,920 ‫And then we simply say, okay, spawn that. 221 00:15:40,970 --> 00:15:42,410 ‫So let's go ahead and do that. 222 00:15:42,410 --> 00:15:52,010 ‫Let's create a game object, let's call the G0 and set that to NULL and then we have a random value. 223 00:15:52,010 --> 00:15:54,950 ‫So let's create the random value range. 224 00:15:55,190 --> 00:15:59,480 ‫We want to randomly create different kind of fruits or different kind of game objects. 225 00:15:59,480 --> 00:16:04,340 ‫For example, the bomb should spawn less often than something else. 226 00:16:05,630 --> 00:16:14,300 ‫So what I'm going to say here, if P is lower than ten, because the value can be between zero and 100. 227 00:16:14,300 --> 00:16:16,670 ‫So if it's lower than ten, then I want to spawn a bump. 228 00:16:16,670 --> 00:16:22,010 ‫So the chance of the bump is roughly 10% or the chance of a bond bump to spawn. 229 00:16:22,010 --> 00:16:27,500 ‫So I'm just going to say G oh is objects to spawn at the position of zero. 230 00:16:27,770 --> 00:16:30,750 ‫So now of course I'll have to take care of this. 231 00:16:30,750 --> 00:16:43,610 ‫So I need to assign the bump at the position of zero and otherwise so else I want to set go with objects 232 00:16:43,610 --> 00:16:57,290 ‫to spawn with a random range between one and objects to spawn length. 233 00:16:57,620 --> 00:17:01,130 ‫So that will do is with the chance of 10%. 234 00:17:01,370 --> 00:17:03,230 ‫I'm going to create a bump. 235 00:17:05,040 --> 00:17:08,730 ‫And with a chance of 90%, I'm going to create a different kind of fruit. 236 00:17:08,730 --> 00:17:15,300 ‫And here, of course, I need to use curly brackets because this is an index that we are trying to assign 237 00:17:15,300 --> 00:17:16,110 ‫this to. 238 00:17:18,060 --> 00:17:24,720 ‫So, once again, 10% chance, it's a bump and 90% chance, it's something random out of all of the 239 00:17:24,720 --> 00:17:28,320 ‫other objects to spawn that we have assigned. 240 00:17:28,620 --> 00:17:32,190 ‫And now, of course, we don't instantiate a fruit to spawn anymore. 241 00:17:32,190 --> 00:17:34,860 ‫We instantiate that game object. 242 00:17:35,250 --> 00:17:40,320 ‫Now, of course, you could you could create an object to spawn what you call fruits to spawn. 243 00:17:40,320 --> 00:17:47,520 ‫And then you could, of course, say public game object bump, and then you could just assign the bump 244 00:17:47,520 --> 00:17:52,710 ‫in here and you could now change gold to be Bob here. 245 00:17:54,930 --> 00:17:56,120 ‫That would be an option. 246 00:17:56,130 --> 00:17:59,550 ‫Of course, your range would be from zero to somewhere. 247 00:17:59,670 --> 00:18:00,870 ‫That would be another option. 248 00:18:00,870 --> 00:18:08,220 ‫Maybe that's even a slightly more intuitive option because the bump is a very specific kind of fruit 249 00:18:08,220 --> 00:18:11,340 ‫and whatever else we add, we can add as we like. 250 00:18:11,340 --> 00:18:16,680 ‫Because the other way that I was just showing you, we would always have to be careful that we assign 251 00:18:16,680 --> 00:18:18,300 ‫the bump to the very first spot. 252 00:18:18,300 --> 00:18:21,210 ‫And we know that because we have created the code. 253 00:18:21,210 --> 00:18:27,360 ‫But if somebody else starts to run the code or starts to edit the code, he might be confused about 254 00:18:27,360 --> 00:18:27,720 ‫that. 255 00:18:28,440 --> 00:18:28,800 ‫All right. 256 00:18:28,800 --> 00:18:32,370 ‫So now we make sure, okay, it's going to be the bob here. 257 00:18:32,520 --> 00:18:33,840 ‫Now, let's save that 258 00:18:36,510 --> 00:18:38,760 ‫and let's go back to Unity. 259 00:18:38,790 --> 00:18:41,130 ‫There you will see what's happening. 260 00:18:41,130 --> 00:18:45,140 ‫So our sponsor should get fruit to spawn. 261 00:18:45,150 --> 00:18:46,740 ‫Currently, it's just the orange. 262 00:18:47,700 --> 00:18:54,120 ‫And after a couple of seconds, it should change from fruit spawn to objects to spawn and bump. 263 00:18:54,150 --> 00:18:54,510 ‫All right. 264 00:18:54,510 --> 00:18:57,000 ‫So there's the bump and the objects to spawn. 265 00:18:57,000 --> 00:19:01,080 ‫And I'm just going to say, currently, it's going to be one object that I want to spawn. 266 00:19:01,350 --> 00:19:06,210 ‫And now let's go to our prefabs and let's drag the orange in there. 267 00:19:08,070 --> 00:19:12,720 ‫So spawn direct the orange in here. 268 00:19:18,350 --> 00:19:19,670 ‫And now about the bomb. 269 00:19:20,750 --> 00:19:22,820 ‫Actually, we don't have a bomb prefab yet. 270 00:19:22,820 --> 00:19:24,340 ‫So let's create a bomb prefab. 271 00:19:24,350 --> 00:19:26,840 ‫Let's drag the bomb into our prefabs folder. 272 00:19:26,840 --> 00:19:31,940 ‫And now let's drag that bomb into our spotter. 273 00:19:35,530 --> 00:19:42,010 ‫In order to test that, maybe we should set the value to 50 here so that there is a 5050 chance that 274 00:19:42,010 --> 00:19:43,750 ‫there is a bump that comes up. 275 00:19:44,050 --> 00:19:47,650 ‫So just to see whether there are bumps or the bumps come in general. 276 00:19:48,940 --> 00:19:49,330 ‫All right. 277 00:19:49,330 --> 00:19:52,330 ‫So there's a bump, oranges, bombs, oranges, bombs. 278 00:19:52,330 --> 00:19:58,520 ‫And if I hit an or a bump, well, I hit it outside, but I hit the bump and now, boom, the game stops. 279 00:19:58,540 --> 00:20:03,160 ‫So now let's see if we well, let's set that back to ten. 280 00:20:03,190 --> 00:20:04,030 ‫That's better. 281 00:20:04,690 --> 00:20:08,500 ‫And now the chance that a bomb comes up will only be 10%. 282 00:20:08,530 --> 00:20:09,220 ‫Of course. 283 00:20:14,100 --> 00:20:17,490 ‫And as you see, oranges, oranges, oranges. 284 00:20:18,090 --> 00:20:20,670 ‫And then we get points all the time. 285 00:20:21,520 --> 00:20:24,180 ‫At one point, a bomb might come up. 286 00:20:24,450 --> 00:20:27,330 ‫So far, none was there. 287 00:20:29,400 --> 00:20:30,180 ‫Actually. 288 00:20:30,180 --> 00:20:30,690 ‫Come on. 289 00:20:30,690 --> 00:20:31,500 ‫Where's the bomb? 290 00:20:33,270 --> 00:20:35,370 ‫As you can see, that's the thing with chances, right? 291 00:20:35,910 --> 00:20:37,590 ‫Chances are just chance. 292 00:20:37,590 --> 00:20:43,230 ‫So it could happen that I get a gazillion oranges here before I get a bump. 293 00:20:43,770 --> 00:20:46,350 ‫Well, the probability is very low and there is a bomb. 294 00:20:46,380 --> 00:20:46,980 ‫Perfect. 295 00:20:47,340 --> 00:20:48,970 ‫All right, so it took quite a bit. 296 00:20:48,990 --> 00:20:55,620 ‫As you can see, I already killed 40 oranges before I got one bomb, which means there's 10%. 297 00:20:55,620 --> 00:20:56,970 ‫Well, it's 10%. 298 00:20:56,970 --> 00:20:58,470 ‫It could happen any time. 299 00:20:58,470 --> 00:21:06,600 ‫And it only happened after almost 40 or maybe even even 50, I think even 50 oranges, because I didn't 300 00:21:06,600 --> 00:21:08,100 ‫hit every single one of them. 301 00:21:08,610 --> 00:21:09,120 ‫All right. 302 00:21:09,120 --> 00:21:16,470 ‫So I'd say let's go to the next video where we will see how to get the game over and to restart into 303 00:21:16,470 --> 00:21:16,980 ‫our game. 304 00:21:16,980 --> 00:21:17,910 ‫So see you there.