1
00:00:04,040 --> 00:00:09,770
Now that all of our core functionality is ready in our game, it's time to take the final steps of play

2
00:00:09,770 --> 00:00:12,680
testing, balancing and building our game.

3
00:00:13,340 --> 00:00:14,700
Before we jump into that low.

4
00:00:14,720 --> 00:00:20,060
We did add a bit of a bug in our last lecture when we were playing with our scorekeeper, because if

5
00:00:20,060 --> 00:00:25,240
we start the game now, when we click on our start button, nothing happens.

6
00:00:25,250 --> 00:00:30,260
Instead, we get an error message in our console and we're getting a null reference exception.

7
00:00:30,260 --> 00:00:33,290
So that's come out of play mode and fix this error.

8
00:00:33,410 --> 00:00:38,390
And one thing I want to show you with errors in the console is not only does it tell you what the problem

9
00:00:38,390 --> 00:00:38,810
is.

10
00:00:38,810 --> 00:00:44,210
So in this case, an object reference is not set to an instance of an object, so it's trying to access

11
00:00:44,210 --> 00:00:45,870
something that doesn't exist.

12
00:00:45,890 --> 00:00:51,350
It will also tell you the script and the method that's causing the problem and also the line where it's

13
00:00:51,350 --> 00:00:52,100
happening.

14
00:00:52,280 --> 00:00:56,930
And if we look at the stack trace down the bottom, we can ignore most of this.

15
00:00:56,930 --> 00:00:59,630
But we essentially read from the bottom up.

16
00:00:59,630 --> 00:01:04,930
And at the top it says that it's the level manager load level on line 18.

17
00:01:04,940 --> 00:01:10,470
And if we click on this link, it will open up our script and place us right at the problem area.

18
00:01:10,490 --> 00:01:15,950
So the problem here is we're trying to access a scorekeeper to reset the school, but there isn't actually

19
00:01:15,950 --> 00:01:18,650
a scorekeeper in our main menu scene yet.

20
00:01:18,650 --> 00:01:22,040
So the problem here doesn't really require a code fix.

21
00:01:22,040 --> 00:01:29,330
Instead, if we close our script, all we need to do is go to our prefabs folder, drag over our scorekeeper,

22
00:01:29,690 --> 00:01:36,890
and now if we hit play and test again, we should find that it works as expected and it does and takes

23
00:01:36,890 --> 00:01:38,120
us into our game.

24
00:01:38,540 --> 00:01:44,090
So with that small bug fixed, the next thing we want to think about is the balancing and play testing

25
00:01:44,090 --> 00:01:44,920
of our game.

26
00:01:44,930 --> 00:01:49,790
So first of all, let's run through all of the scenes and have a think about what else we might need

27
00:01:49,790 --> 00:01:52,010
to add or change for each one.

28
00:01:52,190 --> 00:01:55,190
Our main menu is pretty much good to go.

29
00:01:55,220 --> 00:02:01,760
The only things of concern is the quit button, which won't work for certain platforms like WebGL.

30
00:02:01,760 --> 00:02:07,310
So if we're building to those platforms, we may actually want to go ahead and delete this button from

31
00:02:07,310 --> 00:02:08,389
our menu system.

32
00:02:08,509 --> 00:02:13,550
The other thing we need to think about is potentially adding a credits menu to our start screen.

33
00:02:13,850 --> 00:02:19,280
This would be as simple as adding a new button to our button group for our credits button, and then

34
00:02:19,280 --> 00:02:24,320
we could potentially link this to maybe a new canvas which would overlay on top of the one we already

35
00:02:24,320 --> 00:02:29,420
have and would give us a nice place to give thanks to anyone that helped with the project or credit,

36
00:02:29,420 --> 00:02:32,210
any providers of various assets we might have used.

37
00:02:32,210 --> 00:02:36,470
And with the knowledge you've gained from this section and previous sections, you should be able to

38
00:02:36,470 --> 00:02:38,630
implement that without any problems.

39
00:02:38,780 --> 00:02:42,230
So there are a couple of things to think about with our main menu.

40
00:02:42,260 --> 00:02:47,120
If we head over to our game over menu, I think this one is okay to leave as it is.

41
00:02:47,120 --> 00:02:49,850
It does everything it needs to and nothing else.

42
00:02:49,850 --> 00:02:56,060
But while we're here, one thing we may want to consider for both our main menu and our canvas is if

43
00:02:56,060 --> 00:03:00,230
we head over to the canvas itself and look down at our canvas scaler.

44
00:03:00,260 --> 00:03:06,710
We've given it a reference resolution and we've told it to match width or height, preferring the width.

45
00:03:06,710 --> 00:03:13,100
Now this is fine if we force our game to work in the nine by 16 aspect ratio, but depending on some

46
00:03:13,100 --> 00:03:19,220
of our build settings and what the player is playing on, this could potentially run us into some problems

47
00:03:19,220 --> 00:03:25,370
because if we imagine this screen favoring the width and the player is playing on a 16 by nine aspect

48
00:03:25,370 --> 00:03:30,770
ratio, we're essentially going to see this portion of the screen which is going to potentially cancel

49
00:03:30,770 --> 00:03:34,910
out our quit button on our main menu and our main menu button on the game over.

50
00:03:34,910 --> 00:03:37,370
And it's all just going to look a little bit wrong.

51
00:03:37,370 --> 00:03:39,020
So a couple of options here.

52
00:03:39,020 --> 00:03:45,230
We can instead opt to favor the height of the screen and this would then extend the sides of our screen

53
00:03:45,230 --> 00:03:47,600
or we could go ahead and leave that as is.

54
00:03:47,600 --> 00:03:52,910
And instead of force some of these settings in the project settings, we'll get on to project settings

55
00:03:52,910 --> 00:03:53,690
in a while though.

56
00:03:53,690 --> 00:03:55,940
So let's leave things as they are for now.

57
00:03:55,970 --> 00:03:58,250
It's just something to always be thinking about.

58
00:03:58,250 --> 00:04:02,990
If you've tried to build your game and it all looks a bit strange, try looking at the canvas scale

59
00:04:02,990 --> 00:04:08,150
of first because that's usually in my experience, the biggest problem with most of my projects.

60
00:04:08,240 --> 00:04:11,030
So finally, let's go over and look at our game.

61
00:04:11,300 --> 00:04:16,399
And in here we've got a whole bunch of things that we can tune and tweak, so let's run through them

62
00:04:16,399 --> 00:04:17,269
into.

63
00:04:17,420 --> 00:04:22,430
The first one will be our player and I've actually already gone away and done some additional balancing.

64
00:04:22,430 --> 00:04:26,750
So the values you see in this lecture will be different to ones from previous lectures.

65
00:04:26,750 --> 00:04:32,180
If we head to the player script, this was where we were controlling the speed of our movement and the

66
00:04:32,180 --> 00:04:33,920
constraints of the screen.

67
00:04:33,950 --> 00:04:37,280
So what I've done in here is just change the top padding.

68
00:04:37,280 --> 00:04:42,380
I've brought that up so that the player is constrained to the bottom half of the screen.

69
00:04:42,950 --> 00:04:46,700
Some of the things we may consider is looking at our circle colliders.

70
00:04:46,700 --> 00:04:51,500
So if you're finding that your collisions look a little bit off when you're hitting projectiles or other

71
00:04:51,500 --> 00:04:57,470
enemies, then do be sure to go in and check your collider parameters for your offset and your radius.

72
00:04:57,710 --> 00:05:02,690
I think my health is mostly okay, although we may want to bump that up a little bit for a longer playing

73
00:05:02,690 --> 00:05:03,170
experience.

74
00:05:03,670 --> 00:05:08,200
And from my player, I thought the shooting was mostly okay as well, so I've left that as it is.

75
00:05:08,470 --> 00:05:15,070
However, if we then turn to our enemies, these aren't in our scene, but they are in our prefab folder.

76
00:05:15,370 --> 00:05:21,610
I've gone ahead and added a new enemy type, so I've done this by just duplicating my existing enemy

77
00:05:22,030 --> 00:05:23,360
for each of my enemies.

78
00:05:23,380 --> 00:05:28,030
I've modified the health a little bit because I thought they were a little bit too difficult to kill.

79
00:05:28,030 --> 00:05:34,510
And I've also modified their score so we can see that enemy one has a lower health and a lower score.

80
00:05:34,630 --> 00:05:39,760
And finally on here for the Shooter script, I've gone in and tweaked some of these parameters as well.

81
00:05:39,790 --> 00:05:44,710
There is no exact science, though, and I definitely wouldn't recommend copying the numbers I've used

82
00:05:44,710 --> 00:05:49,060
here because your game may look, fill and play in a very different way.

83
00:05:49,420 --> 00:05:53,530
Finally, on the gameplay front, we've got the waves and the paths.

84
00:05:53,530 --> 00:05:56,840
So rather than just the two normal ones I had before.

85
00:05:56,860 --> 00:06:02,680
I've created a bunch more with different configurations for the path, look and feel, and I've also

86
00:06:02,680 --> 00:06:07,150
created a whole bunch of extra waves with different parameters and different enemies.

87
00:06:07,600 --> 00:06:12,520
And remember, once we've added more waves to our folder, we can add them to the game itself by going

88
00:06:12,520 --> 00:06:15,640
under the enemy spawn and filling out our list.

89
00:06:15,970 --> 00:06:21,010
The final things we really have the option to tweak is in our audio player, where we can control the

90
00:06:21,010 --> 00:06:23,680
volume of different aspects of our game.

91
00:06:23,680 --> 00:06:27,280
So we've got the music volume and the various special effects volumes.

92
00:06:27,280 --> 00:06:33,190
So again, try and balance these so that the music isn't overwhelming and in-your-face and the shooting

93
00:06:33,190 --> 00:06:35,560
doesn't get too annoying if it's happening a lot.

94
00:06:35,860 --> 00:06:40,540
But with everything set up, let's play my game and just see how it looks and feels compared to the

95
00:06:40,540 --> 00:06:41,530
last lecture.

96
00:06:44,150 --> 00:06:48,290
So we start off with exactly the same two waves as we did before.

97
00:06:48,800 --> 00:06:54,470
But once they've finished, we've now got some new waves, new enemies and different patterns we now

98
00:06:54,470 --> 00:06:55,550
have to figure out.

99
00:06:56,300 --> 00:07:01,640
And because the shooting has changed as well, we now have a lot more challenge in the game.

100
00:07:01,910 --> 00:07:05,380
And I'm thinking that this may be a little bit too challenging.

101
00:07:05,390 --> 00:07:11,270
So again, it would be a case of going back in tweaking those numbers a second, third or even fourth

102
00:07:11,270 --> 00:07:16,430
time until we get something that plays nice, feels right, and will be fun for the player.

103
00:07:17,510 --> 00:07:23,180
And whilst we're on the subject of play testing, it's worth remembering that as the game developer,

104
00:07:23,180 --> 00:07:29,210
you are inherently better at your game than anyone else is probably going to be, and as such, you're

105
00:07:29,210 --> 00:07:32,390
going to find the game much easier than it really is.

106
00:07:32,390 --> 00:07:38,210
So it always revives your expectation of the difficulty down to make it playable for other people.

107
00:07:38,600 --> 00:07:43,370
This is also why you're getting external play testers to help us out is important.

108
00:07:43,460 --> 00:07:48,530
With that said though, before we can give our game to play testers, we need to build it so that we

109
00:07:48,530 --> 00:07:49,480
can share it.

110
00:07:49,490 --> 00:07:54,980
So the final thing we want to do is look at how to build the project so we can share it with other people.

111
00:07:55,010 --> 00:08:00,590
So the first step is going to be to come up to file and then down to build settings.

112
00:08:00,740 --> 00:08:04,980
And remember, this is where we came to place the scenes in our build.

113
00:08:05,000 --> 00:08:09,060
But now let's look at the bottom half of this screen with all of the build settings.

114
00:08:09,080 --> 00:08:12,640
Over on the left, we can select a platform to build to.

115
00:08:12,650 --> 00:08:18,380
And depending on how you set up your initial unity install, you may or may not have some of these options

116
00:08:18,380 --> 00:08:19,330
in the list.

117
00:08:19,340 --> 00:08:23,730
At the very least though, you will have a PC, Mac and Linux standalone build.

118
00:08:23,750 --> 00:08:26,510
So from here we could go and build our game.

119
00:08:26,660 --> 00:08:31,910
But I did mention we were potentially going to have some issues with the canvas resolutions and things

120
00:08:31,910 --> 00:08:32,480
like that.

121
00:08:32,480 --> 00:08:38,390
So the way we're going to fix those is if we're heading to our player settings up at the top, we can

122
00:08:38,390 --> 00:08:41,090
set a whole bunch of information like our version number.

123
00:08:41,090 --> 00:08:43,700
We can set a company name and a load of stuff up there.

124
00:08:43,700 --> 00:08:49,550
But what we want to do is come down to our resolution and presentation and we can just roll that out.

125
00:08:49,550 --> 00:08:54,110
And under here we've got a whole bunch of parameters, most of which we can completely ignore.

126
00:08:54,110 --> 00:08:56,840
But the two of note are the top two here.

127
00:08:56,840 --> 00:09:02,240
So we can change the full screen mode and we can select things like full screen or windowed or things

128
00:09:02,240 --> 00:09:02,930
like that.

129
00:09:02,930 --> 00:09:06,350
And also the default is native resolution.

130
00:09:06,350 --> 00:09:13,340
So if we want to try and enforce some kind of resolution, we can uncheck this box and we can set a

131
00:09:13,340 --> 00:09:15,770
default screen width and screen height.

132
00:09:15,770 --> 00:09:19,400
So that's one way to help fix any resolution issues you might encounter.

133
00:09:19,400 --> 00:09:24,980
But rather than setting my game to full screen, I'm going to set it to windowed.

134
00:09:25,190 --> 00:09:27,170
That will get rid of that checkbox option.

135
00:09:27,170 --> 00:09:31,820
And now we'll only have the option to set the screen width and height by default.

136
00:09:31,820 --> 00:09:36,650
With those options set up though, we can now come out of our settings window and back to our build

137
00:09:36,650 --> 00:09:41,660
settings and to build the game we just need to hit build from here.

138
00:09:41,660 --> 00:09:44,450
We then need to select somewhere to build to.

139
00:09:44,450 --> 00:09:50,210
So in our Laser Defender project, let's right click and create a new folder for all of our builds.

140
00:09:50,390 --> 00:09:52,130
Let's call that the builds file.

141
00:09:52,130 --> 00:09:55,250
It doesn't really matter what it's called, but it's nice and descriptive.

142
00:09:55,250 --> 00:10:00,200
And then in here we're going to have a couple of subfolders for the different platforms that we're building

143
00:10:00,230 --> 00:10:00,680
to.

144
00:10:00,920 --> 00:10:05,660
This first one is going to be the standalone build, so we'll select that as our folder.

145
00:10:06,440 --> 00:10:11,310
And now Unity will start building our project depending on the size of the project.

146
00:10:11,330 --> 00:10:14,750
This could take anywhere from a few seconds to a few hours.

147
00:10:15,140 --> 00:10:17,360
In this case, it didn't take too long.

148
00:10:17,360 --> 00:10:22,550
And now that it's finished, it's opened up our folder structure again and we can see all of the files

149
00:10:22,550 --> 00:10:24,170
that are included in this build.

150
00:10:24,200 --> 00:10:27,350
So that's how to build a standalone version of your game.

151
00:10:27,350 --> 00:10:32,420
But when it comes to sharing with the wider world online, people don't tend to like downloading projects

152
00:10:32,420 --> 00:10:33,950
from unknown developers.

153
00:10:33,950 --> 00:10:41,270
So to make your game easier to share, let's head back into unity and instead change our build to WebGL.

154
00:10:41,300 --> 00:10:46,730
This will allow it to be embedded in web pages so that players can play it without having to download

155
00:10:46,730 --> 00:10:47,380
anything.

156
00:10:47,390 --> 00:10:50,630
So let's click on WebGL and switch our platform.

157
00:10:50,720 --> 00:10:54,490
This can take some time depending on the size of your project.

158
00:10:54,500 --> 00:10:59,000
So I'm going to sit and wait for this to work, and I'll be back with you in just a moment.

159
00:10:59,740 --> 00:11:00,200
Okay.

160
00:11:00,220 --> 00:11:05,530
My project has now changed over to be a WebGL build and we can see that's the case with our little unity

161
00:11:05,530 --> 00:11:06,280
logo there.

162
00:11:06,400 --> 00:11:11,440
But before we go ahead and build this project, there's another couple of things we want to fix with

163
00:11:11,440 --> 00:11:12,250
this build.

164
00:11:12,280 --> 00:11:17,980
So if we head down to player settings once again to load up our project settings window in here, the

165
00:11:17,980 --> 00:11:23,230
top of the screen will be the same as it was before, but things like the resolution and presentation

166
00:11:23,230 --> 00:11:24,890
options will all have changed.

167
00:11:24,910 --> 00:11:29,440
So in here we're going to want to set our default canvas width and height.

168
00:11:29,440 --> 00:11:33,490
And this came in by default for me as 960 by 600.

169
00:11:33,730 --> 00:11:39,970
This is actually a 16 by ten ratio and our game should really be nine by 16.

170
00:11:39,970 --> 00:11:42,970
So let's go ahead and change our default canvas size.

171
00:11:42,970 --> 00:11:48,610
And we could go with a smaller scale like this one, so maybe 540 by 960.

172
00:11:49,000 --> 00:11:55,420
And if we head down to the publisher settings, we want to change the compression format to disabled

173
00:11:55,420 --> 00:11:59,530
because a lot of sharing platforms don't like to have this compression in the build.

174
00:11:59,530 --> 00:12:04,130
So if we disable it, they can compress anything they need to on their end instead.

175
00:12:04,150 --> 00:12:10,510
With those two changes, mate, let's go ahead and close our project settings and then build our project

176
00:12:10,810 --> 00:12:12,000
in our builds folder.

177
00:12:12,010 --> 00:12:14,920
Let's create a new folder for our WebGL build.

178
00:12:15,190 --> 00:12:16,990
So we'll call this WebGL.

179
00:12:19,430 --> 00:12:22,540
And then once again, we just need to sit and wait for it.

180
00:12:22,550 --> 00:12:27,410
And while we're waiting for that to work, let's jump over to a site called Share My Game dot com,

181
00:12:27,410 --> 00:12:29,620
which is run by game dev dot TV.

182
00:12:29,630 --> 00:12:34,940
And this is a great place to share your games and your prototypes with other members of the community.

183
00:12:35,030 --> 00:12:40,190
If you've never used the platform before, then the first thing you're going to need to do is to sign

184
00:12:40,190 --> 00:12:41,300
in or sign up.

185
00:12:41,420 --> 00:12:45,200
I've already got an account, so I'm just going to sign in with my Google account.

186
00:12:45,320 --> 00:12:50,840
If this is your first time signing up, then you'll be presented with a whole bunch of options for selecting

187
00:12:50,840 --> 00:12:54,170
your username, setting up profile pictures and all that kind of stuff.

188
00:12:54,170 --> 00:12:59,990
But once you're done to upload a game, you can either come to the home page and click on upload game

189
00:13:00,230 --> 00:13:01,340
or at the top.

190
00:13:01,340 --> 00:13:04,400
Here in the corner we have the upload game like on here.

191
00:13:04,700 --> 00:13:10,160
If we click on this to upload our WebGL build, once it's finished, we're just going to need to drag

192
00:13:10,160 --> 00:13:13,310
our entire WebGL folder into this box.

193
00:13:13,490 --> 00:13:19,370
My game has now finished building, so I'm going to click and drag that over and it will prepare our

194
00:13:19,370 --> 00:13:20,480
upload for us.

195
00:13:20,510 --> 00:13:25,610
This may again take some time, but it's part of the process of getting your games out into the world.

196
00:13:25,880 --> 00:13:31,220
Once that's finished, though, we'll get a congratulations message to say that it has been uploaded

197
00:13:31,220 --> 00:13:32,120
and is pending.

198
00:13:32,120 --> 00:13:36,860
We'll get a sample of our game so we can make sure that everything's working as intended.

199
00:13:38,940 --> 00:13:39,660
At the top here.

200
00:13:39,660 --> 00:13:43,450
We're also going to have the option to delete our upload if we wanted to.

201
00:13:43,470 --> 00:13:48,990
So if anything's wrong and we don't want to put this version up, we can delete this version, go back

202
00:13:48,990 --> 00:13:53,280
to unity and make any tweaks we need to make and then re upload a new version.

203
00:13:53,850 --> 00:13:57,270
Finally, at the bottom, we're going to need to set up some parameters.

204
00:13:57,480 --> 00:14:02,130
Once we're done there, we can save our upload and then that will take us through the remainder of the

205
00:14:02,130 --> 00:14:03,360
uploading process.

206
00:14:03,540 --> 00:14:07,350
And I think that brings us onto your final challenge for this section.

207
00:14:07,620 --> 00:14:10,560
I want you to go ahead and add more content to your game.

208
00:14:10,560 --> 00:14:14,220
So that'll include things like different enemy types, more waves.

209
00:14:14,220 --> 00:14:19,230
And if you're already feeling up to it, you could add some extra functionality like power ups or things

210
00:14:19,230 --> 00:14:20,010
like that.

211
00:14:20,040 --> 00:14:24,090
I also want you to balance your game once you've added this additional content.

212
00:14:24,090 --> 00:14:27,750
So make sure that it all functions and make sure it's fun to play.

213
00:14:27,780 --> 00:14:31,980
And once you've finished balancing your game and you've had play testers, have a go at it as well.

214
00:14:32,010 --> 00:14:36,270
Go ahead and share your game with the community and show off all of your hard work.

215
00:14:36,420 --> 00:14:41,890
Ask the community for feedback on your project, on what you could do better or what should be changed.

216
00:14:41,910 --> 00:14:47,940
And finally, pay this generosity forward from the community by reviewing someone else's game.

217
00:14:48,090 --> 00:14:51,140
Remember, we are all in it together and we're all still learning.

218
00:14:51,150 --> 00:14:56,130
So don't just post your game and expect feedback from others if you're not yourself willing to give

219
00:14:56,130 --> 00:14:57,810
feedback for their projects.

220
00:14:57,930 --> 00:15:02,760
So I look forward to seeing where you've taken your version of Laser Defender, and I'll see you in

221
00:15:02,760 --> 00:15:06,230
the next lecture where we wrap up and review everything we've learnt.

222
00:15:06,240 --> 00:15:07,680
So I'll see you there.

