Now that all of our core functionality is ready in our game, it's time to take the final steps of play
testing, balancing and building our game.
Before we jump into that low.
We did add a bit of a bug in our last lecture when we were playing with our scorekeeper, because if
we start the game now, when we click on our start button, nothing happens.
Instead, we get an error message in our console and we're getting a null reference exception.
So that's come out of play mode and fix this error.
And one thing I want to show you with errors in the console is not only does it tell you what the problem
is.
So in this case, an object reference is not set to an instance of an object, so it's trying to access
something that doesn't exist.
It will also tell you the script and the method that's causing the problem and also the line where it's
happening.
And if we look at the stack trace down the bottom, we can ignore most of this.
But we essentially read from the bottom up.
And at the top it says that it's the level manager load level on line 18.
And if we click on this link, it will open up our script and place us right at the problem area.
So the problem here is we're trying to access a scorekeeper to reset the school, but there isn't actually
a scorekeeper in our main menu scene yet.
So the problem here doesn't really require a code fix.
Instead, if we close our script, all we need to do is go to our prefabs folder, drag over our scorekeeper,
and now if we hit play and test again, we should find that it works as expected and it does and takes
us into our game.
So with that small bug fixed, the next thing we want to think about is the balancing and play testing
of our game.
So first of all, let's run through all of the scenes and have a think about what else we might need
to add or change for each one.
Our main menu is pretty much good to go.
The only things of concern is the quit button, which won't work for certain platforms like WebGL.
So if we're building to those platforms, we may actually want to go ahead and delete this button from
our menu system.
The other thing we need to think about is potentially adding a credits menu to our start screen.
This would be as simple as adding a new button to our button group for our credits button, and then
we could potentially link this to maybe a new canvas which would overlay on top of the one we already
have and would give us a nice place to give thanks to anyone that helped with the project or credit,
any providers of various assets we might have used.
And with the knowledge you've gained from this section and previous sections, you should be able to
implement that without any problems.
So there are a couple of things to think about with our main menu.
If we head over to our game over menu, I think this one is okay to leave as it is.
It does everything it needs to and nothing else.
But while we're here, one thing we may want to consider for both our main menu and our canvas is if
we head over to the canvas itself and look down at our canvas scaler.
We've given it a reference resolution and we've told it to match width or height, preferring the width.
Now this is fine if we force our game to work in the nine by 16 aspect ratio, but depending on some
of our build settings and what the player is playing on, this could potentially run us into some problems
because if we imagine this screen favoring the width and the player is playing on a 16 by nine aspect
ratio, we're essentially going to see this portion of the screen which is going to potentially cancel
out our quit button on our main menu and our main menu button on the game over.
And it's all just going to look a little bit wrong.
So a couple of options here.
We can instead opt to favor the height of the screen and this would then extend the sides of our screen
or we could go ahead and leave that as is.
And instead of force some of these settings in the project settings, we'll get on to project settings
in a while though.
So let's leave things as they are for now.
It's just something to always be thinking about.
If you've tried to build your game and it all looks a bit strange, try looking at the canvas scale
of first because that's usually in my experience, the biggest problem with most of my projects.
So finally, let's go over and look at our game.
And in here we've got a whole bunch of things that we can tune and tweak, so let's run through them
into.
The first one will be our player and I've actually already gone away and done some additional balancing.
So the values you see in this lecture will be different to ones from previous lectures.
If we head to the player script, this was where we were controlling the speed of our movement and the
constraints of the screen.
So what I've done in here is just change the top padding.
I've brought that up so that the player is constrained to the bottom half of the screen.
Some of the things we may consider is looking at our circle colliders.
So if you're finding that your collisions look a little bit off when you're hitting projectiles or other
enemies, then do be sure to go in and check your collider parameters for your offset and your radius.
I think my health is mostly okay, although we may want to bump that up a little bit for a longer playing
experience.
And from my player, I thought the shooting was mostly okay as well, so I've left that as it is.
However, if we then turn to our enemies, these aren't in our scene, but they are in our prefab folder.
I've gone ahead and added a new enemy type, so I've done this by just duplicating my existing enemy
for each of my enemies.
I've modified the health a little bit because I thought they were a little bit too difficult to kill.
And I've also modified their score so we can see that enemy one has a lower health and a lower score.
And finally on here for the Shooter script, I've gone in and tweaked some of these parameters as well.
There is no exact science, though, and I definitely wouldn't recommend copying the numbers I've used
here because your game may look, fill and play in a very different way.
Finally, on the gameplay front, we've got the waves and the paths.
So rather than just the two normal ones I had before.
I've created a bunch more with different configurations for the path, look and feel, and I've also
created a whole bunch of extra waves with different parameters and different enemies.
And remember, once we've added more waves to our folder, we can add them to the game itself by going
under the enemy spawn and filling out our list.
The final things we really have the option to tweak is in our audio player, where we can control the
volume of different aspects of our game.
So we've got the music volume and the various special effects volumes.
So again, try and balance these so that the music isn't overwhelming and in-your-face and the shooting
doesn't get too annoying if it's happening a lot.
But with everything set up, let's play my game and just see how it looks and feels compared to the
last lecture.
So we start off with exactly the same two waves as we did before.
But once they've finished, we've now got some new waves, new enemies and different patterns we now
have to figure out.
And because the shooting has changed as well, we now have a lot more challenge in the game.
And I'm thinking that this may be a little bit too challenging.
So again, it would be a case of going back in tweaking those numbers a second, third or even fourth
time until we get something that plays nice, feels right, and will be fun for the player.
And whilst we're on the subject of play testing, it's worth remembering that as the game developer,
you are inherently better at your game than anyone else is probably going to be, and as such, you're
going to find the game much easier than it really is.
So it always revives your expectation of the difficulty down to make it playable for other people.
This is also why you're getting external play testers to help us out is important.
With that said though, before we can give our game to play testers, we need to build it so that we
can share it.
So the final thing we want to do is look at how to build the project so we can share it with other people.
So the first step is going to be to come up to file and then down to build settings.
And remember, this is where we came to place the scenes in our build.
But now let's look at the bottom half of this screen with all of the build settings.
Over on the left, we can select a platform to build to.
And depending on how you set up your initial unity install, you may or may not have some of these options
in the list.
At the very least though, you will have a PC, Mac and Linux standalone build.
So from here we could go and build our game.
But I did mention we were potentially going to have some issues with the canvas resolutions and things
like that.
So the way we're going to fix those is if we're heading to our player settings up at the top, we can
set a whole bunch of information like our version number.
We can set a company name and a load of stuff up there.
But what we want to do is come down to our resolution and presentation and we can just roll that out.
And under here we've got a whole bunch of parameters, most of which we can completely ignore.
But the two of note are the top two here.
So we can change the full screen mode and we can select things like full screen or windowed or things
like that.
And also the default is native resolution.
So if we want to try and enforce some kind of resolution, we can uncheck this box and we can set a
default screen width and screen height.
So that's one way to help fix any resolution issues you might encounter.
But rather than setting my game to full screen, I'm going to set it to windowed.
That will get rid of that checkbox option.
And now we'll only have the option to set the screen width and height by default.
With those options set up though, we can now come out of our settings window and back to our build
settings and to build the game we just need to hit build from here.
We then need to select somewhere to build to.
So in our Laser Defender project, let's right click and create a new folder for all of our builds.
Let's call that the builds file.
It doesn't really matter what it's called, but it's nice and descriptive.
And then in here we're going to have a couple of subfolders for the different platforms that we're building
to.
This first one is going to be the standalone build, so we'll select that as our folder.
And now Unity will start building our project depending on the size of the project.
This could take anywhere from a few seconds to a few hours.
In this case, it didn't take too long.
And now that it's finished, it's opened up our folder structure again and we can see all of the files
that are included in this build.
So that's how to build a standalone version of your game.
But when it comes to sharing with the wider world online, people don't tend to like downloading projects
from unknown developers.
So to make your game easier to share, let's head back into unity and instead change our build to WebGL.
This will allow it to be embedded in web pages so that players can play it without having to download
anything.
So let's click on WebGL and switch our platform.
This can take some time depending on the size of your project.
So I'm going to sit and wait for this to work, and I'll be back with you in just a moment.
Okay.
My project has now changed over to be a WebGL build and we can see that's the case with our little unity
logo there.
But before we go ahead and build this project, there's another couple of things we want to fix with
this build.
So if we head down to player settings once again to load up our project settings window in here, the
top of the screen will be the same as it was before, but things like the resolution and presentation
options will all have changed.
So in here we're going to want to set our default canvas width and height.
And this came in by default for me as 960 by 600.
This is actually a 16 by ten ratio and our game should really be nine by 16.
So let's go ahead and change our default canvas size.
And we could go with a smaller scale like this one, so maybe 540 by 960.
And if we head down to the publisher settings, we want to change the compression format to disabled
because a lot of sharing platforms don't like to have this compression in the build.
So if we disable it, they can compress anything they need to on their end instead.
With those two changes, mate, let's go ahead and close our project settings and then build our project
in our builds folder.
Let's create a new folder for our WebGL build.
So we'll call this WebGL.
And then once again, we just need to sit and wait for it.
And while we're waiting for that to work, let's jump over to a site called Share My Game dot com,
which is run by game dev dot TV.
And this is a great place to share your games and your prototypes with other members of the community.
If you've never used the platform before, then the first thing you're going to need to do is to sign
in or sign up.
I've already got an account, so I'm just going to sign in with my Google account.
If this is your first time signing up, then you'll be presented with a whole bunch of options for selecting
your username, setting up profile pictures and all that kind of stuff.
But once you're done to upload a game, you can either come to the home page and click on upload game
or at the top.
Here in the corner we have the upload game like on here.
If we click on this to upload our WebGL build, once it's finished, we're just going to need to drag
our entire WebGL folder into this box.
My game has now finished building, so I'm going to click and drag that over and it will prepare our
upload for us.
This may again take some time, but it's part of the process of getting your games out into the world.
Once that's finished, though, we'll get a congratulations message to say that it has been uploaded
and is pending.
We'll get a sample of our game so we can make sure that everything's working as intended.
At the top here.
We're also going to have the option to delete our upload if we wanted to.
So if anything's wrong and we don't want to put this version up, we can delete this version, go back
to unity and make any tweaks we need to make and then re upload a new version.
Finally, at the bottom, we're going to need to set up some parameters.
Once we're done there, we can save our upload and then that will take us through the remainder of the
uploading process.
And I think that brings us onto your final challenge for this section.
I want you to go ahead and add more content to your game.
So that'll include things like different enemy types, more waves.
And if you're already feeling up to it, you could add some extra functionality like power ups or things
like that.
I also want you to balance your game once you've added this additional content.
So make sure that it all functions and make sure it's fun to play.
And once you've finished balancing your game and you've had play testers, have a go at it as well.
Go ahead and share your game with the community and show off all of your hard work.
Ask the community for feedback on your project, on what you could do better or what should be changed.
And finally, pay this generosity forward from the community by reviewing someone else's game.
Remember, we are all in it together and we're all still learning.
So don't just post your game and expect feedback from others if you're not yourself willing to give
feedback for their projects.
So I look forward to seeing where you've taken your version of Laser Defender, and I'll see you in
the next lecture where we wrap up and review everything we've learnt.
So I'll see you there.