Game Engine: Unity
Unity is a game engine that allows designers to create 2D and 3D games. You can use C# (C-sharp) as a scripting language for your projects to give your components commands. Unity was the game engine used to create many games we know, such as Temple Run, Hearthstone, Super Mario Run, Fall Guys, and more!
Based on the research I made, the following are some of the pros and cons of Unity:
- You can download and use it for free
- Unity has an Assets Market built into its interface, which contains great elements that you can instantly download, import and use (a lot of which are free)
- High-quality visuals
- VR development is considered to be a big strength for Unity
- The tutorial videos provided by Unity are comprehensive and easy to follow compared to its competitors
- Very large install with frequent updates
- There are many features that will be locked if you’re using the free version
- Complex interface that requires a learning curve and can be overwhelming
- Navigation and organization can be difficult
Since I’ve taken a Unity workshop a few years back, I thought I’d choose it as the game engine for this class. I watched a series of tutorials (Links to an external site.) on YouTube for creating a simple 2D game on Unity for beginners. The tutorial started with how to download and set up my first project on Unity, followed by accessing Unity Asset Store. I downloaded and imported Pixel Adventure 1 (Links to an external site.), some simple pixel art assets to start with. The file contained elements such as different player designs and terrain tiles.
Setting-up a Terrain Platform
As you can see in the picture below, I started by slicing and laying down the game’s terrain where the player should be walking and jumping using the Terrain Palette tool. The tutorial also instructed on how to layout the game’s background pattern.
Moving along, I learned about character sprites, rigidbodies, colliders, and the overall physics of Unity. There were different character designs to choose from my Art Asset folder, so I picked this funny Ninja Frog 😁
Applying a dynamic rigidbody component to the player allows for it to follow the laws of physics such as gravity and drag. On the other hand, applying the collider box component to the player and the terrain ensures that the player won’t just fall through the terrain and disappear, but instead fall onto the terrain or “collide” onto it. Applying the tilemap collider to terrain can be a bit tricky because it will be initially placed separately on each terrain block, which can be problematic since it causes cracks in the platform. I learned how to utilize composite collider to combine each terrain block as one collider.
Learning a New Language: C#
Next came the tricky part: Adding left and right motion to the player using C# language. I started by downloading Visual Studio, which is the development environment I was about to use for editing my C# script. This was my first time experimenting with this language! Everything still seems confusing and I have a long way to go, but this was a good start.
I followed the tutorial and wrote “if” statements (IF a happens, THEN b happens) that order the player to move left and right whenever I hit the “D” or “A” letter on my keyboard, and later on gave the ability to my player to jump (or move up and down on the Y-axis) whenever I hit the space button. The script that followed was to allow the character to flip whenever it was walking in a certain direction, so for example, after adding this script, when I press “A” on my keyboard, the character would walk to the left and also be facing left.
Next, it was time to fix my main camera in Unity on the player so that whenever the frog moves, the camera follows it. The tutorial instructor showcased two ways in which this can be done: 1) Parenting the camera to my player in the hierarchy tab, and 2) Creating the script that orders the camera to follow the player. The first method was problematic because whenever I hit “A”, the player would walk and flip to the left, flipping the camera along with it, resulting in the scene disappearing. The second method allowed for the camera to follow the frog’s motion without changing direction when the frog walks to the left.
Animating the Frog: Pixel Animation
Finally, it was time to add some animation to my character. There are two types of animations in Unity: 1) Pixel Animation, and 2) Skeletal Animation. Pixel animation is based on frame by frame animation, where you have different movements of a character drawn, and when played quickly they form an animated clip. within the Art Asset I’ve already downloaded, there were different animations (or frames) that came along with my character such as the frog running, jumping, and idle. Idle animation, which is what I added to my character, allows the frog to bounce whenever it’s standing still.
This was the end of the tutorial playlist! Unfortunately, the channel owner should have uploaded the rest of these tutorials months ago, but never did, and I started the series before knowing that, which leaves my result unfinished. Nevertheless, I feel like I’ve learned a lot of basics about unity, and started to get used to its scary interface. Moving forward, I plan on watching more specific videos on certain aspects of Unity, and learning more about C#.
As you can see in the video below, the character movement still needs further refinement, the idle animation must happen only when the character is standing still, and other animations should be added for when the frog jumps or runs. Although it’s unfinished, I’m still happy with what I made!