I use finite state machines (FSMs) a lot when making games, both professionally and in my own projects. I find that dividing complex systems into separate states makes it easier to conceptualizing at visualizing them. This article is a brief description of my implementation of a hierarchical state machine. I’ll provide the source code and an example of how to set it up in the end. The implementation is in C#, but could easily be translated to other languages. Other than that there is nothing that limits this implementation to Unity or game programming (except for the assumption that states…


Blinn Phong with color.

This is an ongoing project that I’ve been working on a for a while. It’s an OpenGL shader/material viewer. I’ve been wanting to set up an OpenGL sandbox project, and I’ve also been interested in trying out the Go programming language. Therefore I decided to try and kill to birds with one stone, and write the application from scratch in Golang. The application probably doesn’t have the best OpenGL abstractions, nor the cleanest Go code, but I’ll try and explain how it’s set up in the following post.

The full source code and associated assets are available on GitHub:


Final result (skybox downloaded from unity Asset Store).

This is simulation/visualization of a black hole and its gravitational lensing effect. It’s probably one of the more useless things I have made (when it comes to game development), but I think it’s kinda cool so I decided to post it here anyway! I’ll post all the source code below. Keep in mind that it’s far from optimized and can be improved in many ways. Also, I will not explain how raymarching and signed distance functions works. There are a lot of very good tutorials for this out there. I used this one for the basic Unity setup: http://flafla2.github.io/2016/10/01/raymarching.html


Image 1. Rough sea water. (Skybox and rocks downloaded from Unity Asset store)


Bait! Arctic Open was a game we created for the Facebook Spaces platform on Oculus Rift and HTC Vive. Its a social VR game that allows you to go ice fishing with up to 4 friends. You can have tournaments, collect different species and interact in various other ways.

It’s a real time multiplayer game built with an authoritative server. The project was a close collaboration with Facebook, who provided the network engine and the avatars that we used.

I acted as tech lead in the team and was responsible for the overall client-server code architecture, feature implementation, feature requests for the network engine (including fixing bugs in it) and creating monthly deliverables to Facebook in the form of pull requests.

The game was released in late 2017 and was features on stage in at the F8 conference.


Wonderglade was a mobile VR game we developed for the Google Daydream platform. It’s a game consisting of a number of mini games tied together in a carnival themes world.

The game was built in Unity and our team was mainly responsible the minigolf game for this project. The main challenge was getting the physics and the user interaction right. The game was heavily reliant on physics (obviously), so we had to make that feel really good for the user without compromising the performance (which was already under pressure from the fact that it was a mobile VR game).


Bait! was the first game I worked on at Resolution Games. Prior to it, we had only released a minor solitaire title, so this was the first major production for the company. The game was build in Unity. I was involved in most parts of it, anything from high level architecture, gameplay feature implementations, audio, physics to shaders and 3rd party plugin integration. After the game was released I took over as tech lead in the team and stayed with it for a number of updates (bug fixes and new features).


When I first joined King I started out in the Candy Crush Saga team as a C++ programmer. The project I was involved in was porting Candy Crush Saga to the Korean social network Kakao Talk. The game was (and still is) heavily reliant on its social network tie ins, but this was all hard coded to use Facebook. When King decided to launch the game in Korea this would no longer suffice, since Facebook was not the prominent social network there. Inviting friends, sending extra lives etc. was all tied to the Facebook social graph and its APIs. Much…


C# event wrapper, Signals!

This is going to be a short post, but I’ll post it anyway. I wanted to share a simple event system that I use both in my own projects and professionally. The reason I created this system is that I like using events since they allows for decoupled code. However, not a huge fan of the standard C# events. They work great and all, but I’m not a fan of the syntax (defining delegates and having them as return values etc for the event etc.

The event implementation (called Signals) is in the same repo as the dependency injection framework…


One of the first things I noticed when I started programming Unity games is that handling references between object/systems is often awkward and not at all robust.

There are a few built in ways you can do this. The most obvious one is assigning references to objects in the editor. Anyone who has ever worked with Unity in a professional way knows that these references get lost every once in a while due to various reasons. E.g. if you rename the field you set the reference in it will be reset. There are also cases when simply cannot do this…

Johan Svensson

Hi all!

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store