Lam Cao's Blog

A Journey in Game Dev

Safe Zone – our game made at Global Jam 2019


I and my 2 other friends decided to participate in the Global Game Jam this year. And here is our game – Safe Zone.

The title explains what home means to us. After dealing with all the ‘bad things’ out there, we just want to go home because it’s the only place we truly feel safe and comfortable. Unfortunately, we just can’t stay at home forever; we got to get out and work (find something to eat) to survive. And that’s the background of our game.

Here is the time line.

  • Friday night: we simply discussed and came up with a good pitch, then set up a project repo. We returned home at 10 everyone went to sleep. Unlike many other teams who instantly started working on their project, we decided to jsut chill and not to stress it.
  • Saturday: We worked remotely for the first half of the day, and in person for the other half. The collaboration went pretty well (no merge conflicts!). We managed to get all the mechanics done and had the first playable version 0.1 by 6 pm. We mostly hung out with other teams for the rest of the day and each went home by 11 pm.
  • Sunday: We met up and continued to improve the game. We animated characters, added music, reworked the map, implemented a new AI. At 5 pm we demo-ed with the 4th build – version 0.4.

This is the first game for 2 of our friends and the second 3D game for me (my side projects I’ve worked on so far are all 2D). We scoped the project quite well this time, which allowed us to finish without having too much stress. Personally, I was also able to explore some Unity’s features I had never used before such as Character Controller, Cinemachine’s extensions and Navigation. They are amazing. We easily won the “Game using AI” prize.

Considering that each of us still had 6-8 hours to sleep each day I think I will call it a success!

[Unity Tips] Did you know that you can have multiple inspectors at the same time?

I often have to switch to the debug view of the inspector to check out backing fields and other hidden stuff. I find it very helpful to just have both views at the same time.

  • Click on the tiny hamburger button on the top right corner.
  • Choose “Add Tabs”
  • Choose “Inspector”
  • Repeat as many times as you like.

How to use Lerp right.

Lerp, or linear interpolation, is a super useful function we all love. However, I often see devs use it in some weird way. I feel like they never bothered to read the documentation. Well, these devs probably didn’t. Here is an example of how not to use Lerp right.

transform.position = Vector3.Lerp(transform.position, endPoint, Time.deltaTime * speed);

I have seen it in random online tutorials, on Unity Answers and StackOverflow. If you know how it works, then you know the code example above makes no sense! Let’s discuss why.


Goodie Assembly is released on Play Store!

Goodie Assembly is a relaxed puzzle game. Slices appear randomly from 8 directions and move toward the center. Player gets coins and points for completing delicious food.

The game is done within 1 month from prototyping to polishing. This is the first game I personally published on a store. To me it’s more about learning how to make a game than making any money. In fact, I learned a great deal about the game industry as I did lots of research on the way. Making games, especially good ones, is slow and demanding, and surviving as an indie dev is even more difficult. That said, I’m really enjoying the craft and not planning to stop anytime soon. Just have to stick to what we love, right?

Anyway, hope you like the game and Merry Christmas!

[Unity Tips] Tint color in PlayMode

We all have been there tweaking a scene, making a ton of changes just to realize we are in PlayMode for the whole time. It is frustrating. Let’s not make the same mistake over and over.

We can set Playmode tint in Edit -> Preferences -> Colors to something extreme like red. Our eyes will just stop us from making any serious changes during PlayMode.


[Unity Tips] Use CompareTag instead of string.Equals

Comparing tags is a thing we all do in every game project at some point but not everyone seems to know about the existence of CompareTag. Unity could really have done a better job documenting this useful method.

In short, use obj.CompareTag("someTag") instead of string comparisions such as obj.tag=="someTag". CompareTag is much faster and will log an error if a tag is not defined, which is a very good thing.

In case of comparing against a list, use list.FirstOrDefault(t=>obj.CompareTag(t))!=null rather than something like list.Contains(obj.tag) for the same reasons.


A singleton utility for gameObjects

I use a fair number of singletons in my game projects. And I think I have written something similar the code block below for too many times now. So have you, probably.

void Awake() 
    if (instance == null)       
        instance = this;
    else if (instance != this)  

Getting tired of copy&pasting that code snippet over and over, I want to archive the same thing in just one line of code. When someone looks at my code, I want them to recognize the singleton pattern in less than half a second – “Oh hell, singleton again!”


How I learned to use State Design Pattern in my game

I learned finite state machine (FSM) in model of computation class at a university. I’ve loved it ever since. It turns out to be one of the most commonly used patterns in game development. State design pattern is not only easy to understand and implement but also very flexible. I think every game programmer should know about it, and ideally how to employ it.

I believe the best way to learn programming patterns is to apply them. In a recent game project, I learn faster by doing than reading or watching even though I enjoy good reads and tutorials from time to time. In a recent project, I had a chance to look closely at and evaluate (many of) the design choices that make FSM either very efficient or extremely painful to debug and maintain.