Ken Chen

Game Developer

Math Deer

Summary of What I Did:

-Programmed a reliable 2D collision system with Unity's raycast.
-Created a movement system with jumping and dashing.
-Programmed platform/coin/obstacle spawn behaviour.
-Programmed a felxible math question generator that also generates a bank of answers.
-Programmed an upgrade/pick up system.
-Created save system to save player's scores/data.

-Created concept pixel art to set the feel of the game.
-Designed the endless running mechanics with math questions.
-Created all the 2D pixel backgrounds, player and UI.

Concept and Gameplay

Game Concept

game-name preview

My idea for the game was a 2D endless runner in a forest, and I wanted the visual to have depth with layers of forest scrolling past.

This concept art consisted of several layers of trees and lights in a parallax scrolling effect giving it more depth in a 2D side scroller along with a run cycle of a deer. I really liked the outcome of this, so it became the aesthetic and feel of the game.

For the gameplay I wanted something a bit more unique to the endless runner, so I decided to add math questions that will help players with mental math.

Gameplay - Movement and Dashing

game-name preview

The player is running endlessly as a deer and there are two actions, jumping and dashing.

game-name preview

Three jumps can be made before touching the ground.

Dashing can be used without limit, but there is a slight cooldown between dashes.

The combination of the two actions allowed for challenging and fun obstacles like what you see here.

Gameplay - Math System

game-name preview

When picking up an upgrade or stars, the player will trigger a math problem that may consist multiple operations and parenthesis.

game-name preview

In order to answer the problem, there will be three answers to choose from, and the player will have to pick up the correct one. If the answer is correct, then the upgrade that was picked up will be applied.

game-name preview

There is also a Math Setting where the player can select the kinds of math problem they wish to practice/play with.

game-name preview

At the end of the run, the player is presented with all the math questions they did during that run.

Gameplay - Upgrades/PowerUps

game-name preview

The game consists of four upgrades and two pickups.

Processes and Challenges

Collision Detection

Whenever the player jumps and lands, it's 2D colliders sinks into the ground collider for a couple frames, then it pops back up making it feel awful. This is probably due to the game being on a very small scale since it's pixel art and Unity doesn't seem to handle physics well in a very small scale.

I used Unity's raycast to detect collisions between the colliders in the Update loop. This is the way it works, the gameobject that needs collision would constantly shoot rays from the origin(collider's edges) at a certain ray length, to detect a hit with another collider. And once it detects a hit, it would set it's X or Y velocity to zero depending on which direction the collision is being detected.

game-name preview

Platform Prefabs

The version of Unity I worked with didn't have nested prefabs yet, and that really killed the workflow. There were specific coin/obstacle patterns I wanted, so generating the coins randomly in a grid based system would not work. In the beginning I had a prefab for every different platforms and in each of the platforms had coin and obstacle prefabs. And without nested prefabs, if I were to make a change to the base coin prefab, the change won't reflect on the coins inside the platform prefab because it is nested within another prefab. So I had to go through them one by one to change it, which would take too long and too inefficient.

I simply broke the cluster of nested prefabs and put them together in the scene so it's just 3 different prefabs grouped together under a gameobject, and I instantiated that gameobject like a prefab. It's not the cleanest/most flexible way to do it, but it worked for what I needed.

game-name preview

Math Question Generator

I wanted to generate random math questions with random operands from 1-9 that had 1 or 2 operators with all 4 basic math operations. But with division in, it would create decimals/fractions, and solving for non-whole numbers would not be fair for the game.

If division is in the problem then I will simply regenerate the divisor as a factor of the dividend.