Decryptor Dev Log - Unity

By Rayan Ghosh

    Hello Mr. Millard! For our project, we created a video game using the Unity Game Engine with C# and made an Arduino controller to go along with it! This part of the development log will track my progress with creating the game, and Kunjal will follow up with her work on the Arduino side of the project!

    For a background with my experience with Unity, I have been using Unity for almost 5 years now, and I am quite experienced with the engine and its capabilities. I could have gone with a generic project that I have done hundreds of times like a Super Mario Bros clone, but I wanted to challenge myself. Taking an AP course is always about its challenges, and making a project devoid of challenges would defeat the purpose of taking this course.

    This is why I decided to make something I had never made before: a memory game. I drew inspiration from Quizlet’s memory match mode, where the player must match a vocabulary word to its definition with corresponding tiles.

    The creation of buttons and simple checking of errors between all of the buttons was pretty simple:

    But the real troubles began when I wanted to make a random question selection for the buttons. The solution was obvious in my head: I wanted to use Dictionaries since they conveniently have a Key:Value format that would work quite well with my Vocab:Definition way of styling the cards.

    The only problem was that while Unity uses C#, which has support for dictionaries, the dictionaries would not show up in the actual Unity Editor program, making it a hassle to implement the questions Bill had made for the memory game (it would all have to be hardcoded).

    So, after researching a solution, I found this Reddit post, which had a link to UDictionary, a third-party script someone had made to address this problem. (Reddit Post)

    The implementation for these dictionaries into my script once downloading the script mentioned in the Reddit post was simple:

    The unity look at things down here

    Then all I needed to do was scramble the cards around so the player couldn’t memorize the matching patterns.

    I also implemented a way to select cards through “coordinate” positions I placed manually in the editor with key presses to help Kunjal when she got to making Arduino support.

the anchored positions of each card to a painstaking amount of significant figures

    All of this took around 4 or 5 class periods to complete. While I had achieved in challenging myself and finishing the project, I felt that the game was quite boring, so I added some additional gameplay to get people to keep playing the game with a fun speed-based platforming game in between each memory game section.

    I have created platformers at least 20 or so times before (I even taught how to make a 2D Platformer in my Game Development Club last year) so I wanted to have the player do something that I have never coded before: Wall Jumping

    I have played games like Hollow Knight that used wall jumping to add a little extra challenge to the regular jumping gameplay, and I thought that it might be a fun edition here.

    Unity has a built-in physics system using Rigidbody 2Ds so I used the velocity component of that to apply forces for sideways and jump movement (I also decided to make a double jump, so the player can jump once on the ground and once in the air):

    The BounceUp Function just applies a really quick animation of the player squishing by hardcoding the player's x and y scale with a component called the transform (essentially the rotation, scale, and position of an object).

    The Two() function uses this game design principle called Object Pooling, where we create a lot of invisible objects and the start of the game and cycle through them when we need particles instead of spawning a new particle object to preserve memory.

    The Wall Jump code was quite similar to the way I created the Double Jump, making timer between the jumps and applying a force in the direction the player jumped off an object with the wall layer.

    Once the basic player movement was finished, I got Samuel to create some levels based on the mechanics and got other things like moving platforms (grabs 2 positions, interpolates between them) and spikes which restarted the level on collision.

    The goal of each level is to get the plug and receive the cord so that you can go into the memory game

    One really important game design concept I wanted to add was the ability to complete the level in different ways, even though the design was simple, and Samuel helped make this vision come to life.

    During playtesting, people did not want to play the memory game, so I made an option to not have to. I did this by making an invisible game object with a script attached that tracked if you clicked the appropriate option in the menu for that.

    One final mechanic I added was the timer. A timer that goes between all levels including the memory game levels, and gives you your final time by the end:

    Another final mechanic I added was level art. I wanted each level to have a special color and texture to it, but I did not want to make a lot of art. So, I used a fun sprite masking technique I learned from this BlackThornProd video. Then, I added a Post-Processing (effects to camera) randomized filter to change the gradient of each level through script:

    Finally, the game was complete. This concludes my part of this project. It was time to make things even cooler with some Arduino support! Kunjal wrote about her arduino part here.

Copyright 2023

For Team Access Only:

Sign In