UnityLearn – Intermediate Programming – Pt. 01
September 30, 2019
Intermediate Programming: Unity Game Dev Courses
Swords and Shovels: Game Managers, Loaders, and the Game Loop
Intermediate Programming: Unity Game Dev Courses
Unity Learn Course – Intermediate Programming
What is a GameManager?
Game Systems
Many parts of your game will need to communicate with one another. You can directly makes these connections between different objects as needed as a way to accomplish this. This method however does not scale well, and becomes very complicated and hard to debug.
This is where the concept of having a GameManager comes in. This provides a central location where systems can communicate through. They can also hold important central data.
The tutorial’s basic definition of a GameManager was “A central location for data” which can serve one of the following purposes or both:
- Determines who can change what
- Informs other systems of changes
This Swords and Shovels tutorial will specifically use their GameManager for rule management and some informing.
Persistent Systems
The GameManager needs to be accessible to all the systems that need it. The GameManager should be globally accessible for the life of the game.
Unity Containers
They reference Scenes and Prefabs as Unity Containers. They represent collections of assets and use particular scripts to connect them. In Unity, Scenes are generally large collections of assets, while Prefabs are for smaller collections.
One technique is to have a persistent scene which contains all of your managers, since it will most likely even have responsibilities for loading and unloading other scenes. This is the technique that will be used in this tutorial. This also happens to be the technique I was using on my personal tower defense scene management project.
Preparing to Build a GameManager
You most likely will not be able to design and construct the perfect GameManager for your game immediately. Games are organic objects and you will need to change and adapt your systems as you build in most cases. With this in mind, it is important to build in a way that supports growth (but without over designing).
When starting to make your GameManager then, you want to layout the basic requirements you know it must have. The requirements for this tutorial are:
- Tracks What Level Is Being Played
- Can Create Other Global Managers (i.e. Audio manager, Game Save manager)
- Knows the Current State of the Game
- Can Cleanup Game Systems (i.e. Save game on quit, send message to server indicating how game ended)
Setting Up Your Scenes
This part finally gets into working with the Unity project. There was a package to download that contained all the necessary objects to get you up to speed to start working at this point.
When you create a script named GameManager in Unity now, it gets a unique icon that looks like a gear. This does not particularly do anything special, it is just a visual to help you identify the GameManager since it is normally a more important class.
This step mostly just wanted to have you get the package loaded in, create the GameManager script, and make a new Boot scene that will handle starting everything (as well as put that scene in the build settings). It also mentions how it is important to put all your scenes in the build settings to make sure they are accessible with your system.
FINAL NOTES
There is a actually a lot going on with the package I obtained for this tutorial, so it may be worth looking into the beginner part of this tutorial before progressing with this part. Even though it will most likely cover a lot that I already know, I think there is still a good bit of valuable information for me to gain from going through it.