Not only do you have to design a way to play and win a game, but you also have to write code to make sure everything is displayed appropriately on the screen. Every character, collision, goal, point, animation, and resource needs to be properly coded so that the player has the right experience. The one you’ve dreamed about.
With tools like Unity, I may never get through these books and I may never need to. If you are an aspiring game developer, there are so many tools out in the wild now that there are almost no excuses left for you to start.
As an educator, my number one priority with learning something new is also learning how I can share my knowledge with others. When learning a new system or how to create a new type of project, I’m apprehensive about programs “doing things” for me.
My number one concern with learning Unity has been, “How much is Unity going to do for me? Can I use Unity to learn new things AND use what I have already learned?” I’ve run into similar situations with creating web projects in Visual Studio.
For example, you can start a new website project in Visual Studio, press F5, and boom you have a website! You also have a bunch of code that you did not write and it could take you a while to fully understand what was made for you. Sure I can read through the code, but can my students understand what’s going on? Do they understand the problem that’s being solved and can they appreciate how much of the heavy lifting has been done for them? More importantly, if something goes wrong, will they know how to fix it?
I can assure that they can because I have come to realize that Unity is not an automation tool. It is a tool that facilitates creativity. Unity has taken care of screen animation, memory management, and other low-level elements of game development so that you can focus on adding content and getting your game started. If you run into a roadblock, it is not because Unity added a reference to some mystery class that they have hidden from you. You are in the driverseat. This is the story of how I finally got my start as a game dev with Unity and where I’m going with my journey.
Getting In and Going Fast
Out of my way, Unity! I know what I’m doing! I have a design doc with me, I have a few class diagrams, some awesome sprites for the characters, and a master’s degree in Information Systems with a love for Object Oriented Programming. I’ve taught several lessons on project management and I have a full project plan for a video game sitting on my desk. I am ready. Or, so I thought.
I open up Unity and the excitement fades a little bit. I’ve stepped onto a new road and I’m not sure where it actually begins. What gave me the most anxiety was this large “Play” button in the middle of the screen. When I press that button, how will I know what’s going to happen first? Where’s the ‘main’ method? I have all these great plans and I don’t know where anything goes.
How can Unity help me achieve my goals? I know that Unity has been the foundation for other 2D Platformers out there. There must be some way to import my design into the Unity engine. Naturally, I did what any developer looking for help would do. I rolled up my sleeves and went searching through the wild untamed lands of the internet.
Setting Course - Navigating Through Tutorials and Libraries
Before I hit the road on my game dev journey, I started a Google doc to keep as a log. This one long thread serves as a log of my game progress and as a list of references to the great material Unity has put together. I set a course for moving a 2D character on a screen and ran into my first roadblock: analysis paralysis.
There are so many ways to use the Unity tool, but how will I know if I made the right call? I could use keys for user input or an axis so that the gameplay is platform independent. Collision detection could be layer-based or I could use ray-casting. One YouTuber actually recommended Googling ‘2D Character Controller,’ and copy/pasting the code into your project. What can you learn from that?
I found that the official training from the Unity site as well as their blog posts and live streams from their conferences to be the best tools. I started to put my trust in Unity as a company to show me the best way to use their product and it has greatly surpassed my expectations. They WANT you to make games and they want you to make games your way. Please make sure you explore the wonders that is Unity documentation. Unity also provides tutorials, blogs, and live training sessions. This blog post in particular helped me to understand how to test your gameplay logic using automated tests.
It’s through these tutorials that I found the ‘main’ class I was looking for. The MonoBehavior. This is the base class for your Unity scripts. Make no mistake, you will have to write code for your game and using a MonoBehavior is where you get your start. It’s also where I ran into my next roadblock.
Now that I’ve become more familiar with Unity, I’m ready to add my code! I adjusted my character designs so that they inherit from the MonoBehavior class and so that I can easily test them using Unit Testing. This will allow me to make changes and run automated tests instead of play-testing each time I make a change. I write my first test, hit play, and a giant error message is thrown right into the console. You cannot instantiate MonoBehaviors.
I felt heavy. What have I done? How could I have been lead this way? All my classes and characters are ready to go, where did I go wrong? I went back to Unity and saw that the MonoBehavior is essentially the script that is added to a character or GameObject in Unity. In other words, Unity will let you use a MonoBehavior so that your code can be used within the engine, but you cannot create a MonoBehavior outside of Unity.
That’s when it hit me. There’s a reason why it’s called Unity scripting. Unity acts as a facilitator. All those worries that I had from my Java book: Page-flipping, memory management, gravity, it’s all been taken care of for you. Unity has built the engine, no, the car for you. You still need to drive.
Enjoying the Ride
The more comfortable I become with Unity as the facilitator, the faster my development gets. So many things have been taken care of! Want some gravity? Click on the checkbox in the Inspector, or set the gravity in your script. Should the player experience a bit of drag? There’s a method for that! What business is it of mine to try to bring balance and order to the universe? Unity has given me the sandbox I need. As a result, I’ve been able to tweak the physics settings of my game while performing a live play-test instead of making code changes and waiting for the game to rebuild.
My current project deals with characters whose abilities become stronger when they are in water. I know that water levels have a history of making gamers cringe, so I want to spend a lot of time on this mechanic. Unity gives you a way to try things out before you make your code changes, allowing you to experiment and save time in the process.
While working on underwater physics, I was able to adjust the physics settings using the Unity GUI during live play-tests. I then updated my code using the values I set during the test by adding references to the Unity Scripting API. Adding a value to the ‘draft’ property while playtesting let me get just the right feel before cementing the draft value in my code.
Embracing the features of the tool has allowed me to experiment with ease. Unity is similar to Ableton in that it fosters creativity and does not restrict it. It has also been a blast seeing all of my lectures that deal with Rapid Prototyping, SOLID, and a bit of TDD be realized in a fun and exciting way.
Will I get to those dusty old game programming books? Probably not, but Unity can also be a great starting point for new programmers. The UI will help you set the scene, but the only way to have full control of your game is to add code to it.
Now is the time to make the game you have been wanting to make. I can assure you that you will not get lost and that learning how to build a game in Unity does not mean you have to be tied to Unity. Unity will be your guide to further understanding how games work. Unity has taken care of all of the heavy lifting for you and it’s community is all too eager to help you. The car is on, the engine is running. Get in.
Ready to talk shop about your own Unity road trip adventures? Join the Mega Cat Discord today!