Follow by Email

Monday, 28 April 2014

How to prototype in Unity. The Magic Rule of 3.

It doesn't matter if you work in a big company or you are a one-man team. Ideas doesn't fall down from the trees, and success comes with the price of many failures. That's why you will need prototypes! The art of prototyping consist in being able to test ideas better and faster. In this article I will be talking about two things. First I will make an introduction to prototyping and then I will explain why Unity is the ultimate prototyping tool for video games.

While documenting myself before writing this post, I stumbled across many very interesting articles about how to make video game prototypes (written by people with far more experience than me). Here I will comment two of them that I recommend reading.

The first is a rather old post from Gamasutra. How to prototype a game in 7 days is very complete, and has some revealing facts that I never though about before. It focuses on the fact that "Formal Brainstorming Has a 0% Success Rate". The sentence is quite true, but I will talk a little bit more about it later on the post. It also mentions "Nobody Knows How You Made it, and Nobody Cares" witch means that you should be building prototypes maximising outcome, even if that means forgetting about Software Engineering and good programming techniques.

The second article is from Rapid Game Prototyping: Tips for Programmers is a more practical guide of what to do and don't. It also has some interesting ideas like: "If a task is not moving you closer to your goal, don’t do it.". Don't waste your time, the only thing that should survive prototyping are ideas, not code. "When you are in the mud, get out of it, and move on". Use all the dirty tricks you know to fake the final idea of game and don't stop on details that burn your time.

Prototype of Northwards of Roswell, still in development. This state was achieved in 2 hours.

Monday, 21 April 2014

Simple debugging in Unity. Cheap and Painless.

Debugging with Unity can be done very easily. You can for example, connect MonoDevelop to the Unity editor and set breakpoints and all that kind of stuff. This is explained pretty well in the official documentation here, so I will not talk about it on this post. Instead I will explain some alternative methods and tricks that can help you to debug your game that can be sometimes more convenient (because they are Unity exclusive).

First of all, I would like to remark that while you are making any program, great amount of your time and efforts is spent debugging. Depending on your methodology, the amount of time can be lower. In an ideal situation you would be using a TDD aproach, so you fix your bugs before they occur. Unity made a big step releasing the official test tools for Unity (I will write a post about such great plugin in the future). But the sad truth is that many times you can´t just write tests for a videogame.

Bug free software. What a big lie!

Your biggest friend while debugging in the Unity editor will be the console. The console will capture the prints and logs from your code and display them in the editor. It will also retain a reference to the monobehavior involved in the cast if you want (context), so you can click on a console message and the GameObject will be highlighted.

There is many ways of sending messages to the console. The first is using the static class Debug. Debug allows you to Log messages with context, errors, exceptions and warnings. There is another function called print (a wrapper for Debug.Log in the monobehaviour classes). These are all pretty much the same, the difference is that errors can stop the editor if the "Error Pause" option is selected in the console. If you double-click on the console line, it will point the line in the code where the error or log is inside monodevelop.

Click to highlight the context. Double click to go to the code.

Monday, 14 April 2014

Video games and Learning. Beyond Educational games.

There is a big misconception about video games and their education value. Most of the world agrees that "educational" video games really teach people things. Most of this games are designed for kids. Why? Because there is people out there that still thinks that video games are something bad and a waste of time.

Here is a little secret: 
All games are educational! 

Truth is, that the only difference between educational games and normal games are the first are usually more boring. The attempt to add obvious educational content to the games fails most of the time just because it was not needed. It is a wrong approach.

There is something to learn from every game. In an engaging way.

Everyone knows that the first step to successful learning is interest. If something is not interesting or is not meaningful to you, you will spend a lot of time and energy for little benefit. Games are good way of keep the learner motivated and so, create a great environment to improve the knowledge and skills of the player. 

There are of course more steps in successful learning. Many of them are described in Gee's video. I totally recommend to watch it from the beginning to the end. At some point he mentions that one of the reasons of why the games are so good at teaching is because games need to, in order to sell. If you find a good game it will necessary be good at teaching.

Friday, 11 April 2014

Single Responsability Principle. Disassembling Singlenton in Unity

If you ask me what is the most important of the SOLID principles that you should follow when developing for Unity, I would say the first. The Single Responsibility Principle (SRP) states that "Every class should have a single responsibility, and that responsibility should be entirely encapsulated by the class", also that "All its services should be narrowly aligned with that responsibility". In other words, don't mix beer and wine.

This can be sometimes complicated in different programming languages, but looks like Unity was created to specifically follow this rule. Because most of the logic of a game object is something you do not have to care about, you can create different behaviours that will do very simple things.

Singleton UML diagram. The simplest design pattern I could think of... xD

The example I will work with is the Singleton Pattern. The singleton is used a lot in Unity to have items that have to survive different game scenes. At the same time, you don't want that game object to duplicate while navigating though the game. The script below ensure that already, you just need to add in the Start or Update your functionality. For example: Game Controlling or Background Music.

Monday, 7 April 2014

Working in Team Basics. Unity and Git.

If you are an small development studio and decide go for Unity, you will not regret. Although, there are some things you would like to know before continuing. In Mofables we migrated from Cocos2D to Unity four months ago. It was at the time I joined the company, so it was in my hands to decide the road map.

Like always, I will be talking mainly about free or cheap solutions. Everyone knows that you can buy a team licence from Unity Technologies that will help your greatly to share your work and keep it safe. There are many solutions like that, but are very expensive and definitive "no" for people witch is just starting and can't really take advantage of them.

The first thing you need to do to get things up and running is setting up a collaborative environment. Depending on the size and competencies or your team this can be easier or harder. To simplify the things, let's imagine your team is composed of 4 people. You may be interested in Agile Methodologies such as SCRUM or Kanban, I recommend Trello for tracking and planning.

Trello is free and very versatile. There is a plug in to support Scrum for your browser.

You can use pretty much any kind of repository, but I really recommend Git. Git is fully distributed, witch means that everyone's work will be independent and faster. Also there are plenty of web pages like Bitbucket, where you can get your projects hosted privately, for free and without limits. Also the use of some client like SmartGit will allow everyone in the team to collaborate without knowing how repositories really work.

Friday, 4 April 2014

iBeacons in Unity. Asset Store Review.

This is a review about an Unity plug-in that you can find in the Assets Store. The component is called iBeacon and costs 15$. For a technological solution of that kind, I think is a fair price. The plug-in is the first of its kind in the Asset Store and it doesn't have any review yet. So let's get to it!

IBeacons are low-powered bluetooth devices. They are small as an egg and have a battery that can last years. Phones and tablets are able to connect to them an receive information witch makes location-based apps very convenient.

It main purpose of the iBeacons is shops, museums and touristic places. That sounds quite boring to be honest. Why not make some game with it? :)

Estimote iBeacons are one of the most popular. Cool design.