The new year is come, full of good resolutions and appealing feelings of renovation. For my part I have two main target. The first one is to write a bit more. I always feel that I have a lot to say but, for some reason, I usually get stuck in a kind of writer’s block every time I finally found time for writing. So, because the only way to beat a writer’s block is to write, and write and write, I decided to spend at least January into a more strict scheduling. Maybe there will be a good impact in the blog post frequency too.
The second “resolution” is to beat the One Game A Month challenge for 2015. The goal is to complete a game each month. You don’t have to realize the full game in one month, you just have to complete and release it. I think it is a nice opportunity to challenge myself on some specific game development aspect while forcing some deadline (that is always a good thing).
However, taking advantage of the Ludum Dare jam on December, I started this challenge a bit in advance. :) So, now I’m going to do short post-analysis of my game for the previous month.
The GoalEach month I’d like to take one thing I don’t know well and trying to build a game using it. This month I had no specific idea (because I didn’t ever started to think about this 12 month challenge :D) but I can say that the main learning element of the December game was to learn the new Unity UI system.
Moreover, the Ludum Dare theme was “the full game in one screen”.
The Idea - Ninja FarmerWhen I started the game I knew that, because of holiday and personal stuff I could spend only a short amount of time on this game. So I chose something very simple: a small casual game in which a farmer have to hit the chicken in order to score as much points (eggs?) as possible in 30 seconds. There are some “dexterity tricks” in order to boost your score :
- Bounces: To hit the chicken after bouncing on the screen border increase the score multiplier.
- Non-Stop-Shoot: Shooting the farmer before it stops provide a fixed amount of bonus score.
- Combo: To hit the chicken multiple times with a single shoot increase the score multiplier.
The ImplementationWhen I work in Unity usually I tend to over-code. This time, a bit for lack of time, a bit for curiosity, I tried to code as less as possible and let that the game engine was working for me.
The main element of the game is the ability to lunch the farmer around, to hit the chicken and to bounce on the boundaries. To do that we can simply exploit the 2D physics capabilities of Unity.
We can work in the following way:
- First, we make sure that the camera is well configured for 2D with fixed resolution. This will avoid many problems in the future.
- Then we create 4 kinematic rigid-objects with no mesh and a cubic collider.
- We start to position these blocks on the boundaries of the “field” such that the internal edge of of the collider is slightly outside the camera view.
- We add a collider to the farmer and the chicken too (remember to turn off gravity).
- We add a physical material on the boundaries, the farmer and the chicken and we tone them in order to obtain the desired bounciness.
The Unity UIThe biggest news for me is to start working with the new long-awaited Unity UI system. It is a bit complex at the beginning but I have to admit that, at the end, it is just as a good UI system should be: modular, easy to interact with and customizable.
The main difficulty for a beginner, I think, are the three different rendering modes. I’ll try to explain what I learned in the last month.
Screen Space OverlayThis is the first (and default) mode. It corresponds to the GUI rendered directly in screen space. For this reason, all the coordinates are expressed as pixels in the final viewport.
The behavior of this canvas in the editor is a bit strange in the sense the working with pixel art games I found the widget embedded in this SUPERHUGE canvas spreading for hundreds of unity-meters (while my pixel-world is in the 1-2 range). There should be a way to “fix” this behavior but, anyway, the results is good.
I used this mode for the main menu, the game over screen and the fixed overlay in the game (score, combos, other data).
Note that a canvas in this mode will be always on top of the other game objects.
Screen Space CameraAlso if this is defined as “Screen Space”, I found more easy to think at this mode as a world space mode. The difference with the real world space is that the canvas position is automatically arranged in front of the chosen camera (that can also be the main camera). This allow two things: 3D transformations on the widgets and the fact that the widget appear in the editor in some “understandable” position.
I like a lot this mode for in game UI. I used this mode for the big time clock that wanted to be on top of everything but the farmer and the chicken.
World SpaceThis is the real world space mode. In this mode your canvas is just a square in the world, it’s your duty to make it facing the camera and being visible.
I used this mode for all the dynamic GUI elements in the game (for instance, text who spawn on the chicken/farmer).
What is missingThere are a lot of things that are missing in this game. First of all graphic. I’m not a good artist and to make something nice I needed more time than the one I had.
However, this is not the main problem for me. I think the main deficit is in the gameplay and in particular in one keypoint: exploration
Exploration is the aspect of gameplay that describe the desire for the player to keep playing. It is the reason because so many games nowadays contain an upgrade system.
An upgrade system is based on a simple concept: collect in-game currency in order to buy upgrades that allow you to collect more currency that allow you to buy more powerful upgrades, and so on. It is a very simple mechanic but it is extremely effective. I personally spent an huge amount of time on some horrible games, just to unlock some powerful upgrade.
Well, Ninja Farmer is definitely a good candidate for an upgrade system or some other type of exploration-based-improvement. Because getting an high score is simply not enough. Unfortunately I didn’t managed to implement anything of this, also because most of the “upgrades” I designed require some non-trivial graphical effort.