Unity tag system sucks

One of the first things that I learned when I started to work with Unity is its tag system. It is very easy to understand as it is based on a concept of categorizing game objects into groups. Each game object belongs to a single group. Unity provides a convenient mechanism for checking whether a game object belongs to a group or not. You can also find a game object, or all game objects, of a group.

But the system does have a flaw. You cannot assign two or more "tags" to a game object, and this is quite annoying. For example, your bullets already had the "Bullet" tag, but you cannot tell who owns each one of those bullets, the player or the enemy thief. In this post, I offer a solution as a replacement for Unity tag system.

Continue reading Unity tag system sucks

A simple Object Pool for better performance for your games

With game programmers, optimization and performance are interesting things to discuss. We all love to squeeze our hardware as much as possible, to achieve more stunning graphics, more attracting gameplay, with the best performance (damn that's greedy). Object Pool is one of the common technique of optimizing game performance, and today I'll show you my object pool implementation. It's simple, easy to do and most of all, its real-life use is very close to Unity's mechanism of creating and destroying objects.

Continue reading A simple Object Pool for better performance for your games

Extend the State design pattern for AI

In my previous post, I discussed the State pattern. This is a pattern that helps you to delegate and wrap functionalities into state objects. While it allows you to get rid of annoying and complicated if-else statements, it also is a good way to make your code more modular and decoupled, because state classes know very little of each other.

Continue reading Extend the State design pattern for AI

Create a multi-function button in Unity using State Design Pattern

The Problem

Today at work, I was assigned a task of implementing a button - it seems to be a trivial task. There is an interesting point of this button, though. It reacts differently in different situations, that's why I call this button "multi-function". Continue reading Create a multi-function button in Unity using State Design Pattern

Unity's [SerializeField] demystified

Hi there, Unity developers!

As you work with Unity Editor, you use the Inspector window pretty frequently. From here, you can do many things in order to have your Unity game works as intended, such as modifying graphics quality, increasing the value of gravity, or changing a texture's import settings. But I believe most of us spend most of our time with Inspector window to tweak our GameObjects and their values. For programmers, in Unity 101 lessons, we learned that a public attribute would show up in the Inspector window.

However, making an attribute public is not always healthy for your code... Continue reading Unity's [SerializeField] demystified