These days, pretty much everyone is familiar with the tycoon or simulation/management genre where you as a player manage some kind of a business, sports team or even an entire country. Throughout the decades, many famous titles have been released such as Rollercoaster Tycoon, Railroad Tycoon, SimCity and Theme Hospital just to name a few. These titles have sort of set the standard and have inspired an entire generation of game developers to create their own type of tycoon game in Unity.
Perhaps you yourself are thinking about developing a tycoon game in Unity. However, you might ask yourself some questions. You might wonder how difficult it is to build tycoon/management game in Unity and even if Unity is right engine to build it in. As It turns out, Unity is a perfectly fine choice to make such an game. Yet, you will have to change your preferred way of working a little. Below are some tips that will help you get started.
1. Don’t use MonoBehaviour for Everything
Of course, every Unity Developer is well aware of the MonoBehaviour class as it effectively creates an interface between the Unity engine and your game code. While it is incredibly tempting to build your logic on top of MonoBehaviours we urge you to take a different approach.
Instead, we recommend you to actually build a data model in C# which can be visualized in Unity using MonoBehaviours. This essentially forces a clear separation between data and visualization. If you have a background in software design, then you might realize what we’re actually talking about is similar to a Model View Controller architecture or MVC for short.
Imagine a scenario where we are building a game like SimCity and we are tasked with making sure the road is populated with cars. Now, rather than having each car be represented by a MonoBehaviour we would create a data structure that describes a car driving on a particular road.
As a result, the car you see in the game would actually be a visual interpretation or interpolation of what is happening in the data structure.
Why this is so important to get right will be clear as you read through the next set of tips. Even if you decide to stop reading from here, the takeaway from this whole article is that you separate your data from your visualization in some form or another. This will make it considerably easier to develop a tycoon game in Unity in the long run.
2. Custom Simulation Tick
Now, if you were to look under the hood of any simulation/management game you will find that it is a program that is effectively a big number cruncher. Each game loop, this program is keeping track of thousands of objects, each with it’s own set of values. Over the years, computers have become ever more powerful, allowing developers to make even more elaborate simulation rules than they did before.
When starting to work on your tycoon game in Unity, it could come in handy to implement your own simulation tick that is running independently from the one offered by Unity through its MonoBehaviour.Update() method. The reason for this is that rolling your own simulation tick will effectively give you the option to run your simulation at different speeds, independently from Unity.
Perhaps you want to implement a feature that allows a player to slow down or speed up time. This becomes quite a trivial task when leveraging your own simulation tick. Finally, another advantage to having your own simulation tick is that it gives you more control over scenarios during Unit Testing. (More about that in tip 4).
3. Batching Operations
Every once in a while, whilst playing a management/simulation type game, you may have noticed a small delay after you have ordered something to be done in the game. Most often this can be found if the order involves a rather complex (meaning computationally expensive) algorithm that needs to run on the background. You can often see this happening in large games with plenty of objects engaging in path finding. So what is this delay about? What you’re seeing here are batched operations.
In order to manage the strain of running many complex algorithms at run time, it is common place to run such algorithms in batches where each algorithms is basically an operation. Rather than having the game stall for a few milliseconds, it is better to spread out heavy cost of these operations over the course of several game loops.
Of course you might also consider implementing a large part of your simulation logic using multithreading. Potentially even leveraging Unity’s Job system to do most of the management work for you in a cross platform way. This is completely up to you, but be aware that multithreading your simulation code comes with it’s own set of challenges and dangers that we will not cover in this article.
4. Unit Testing
One of the challenges in developing a simulation or management type game is the fact that you’re dealing with an incredible amount of tweakable values. While playing your game, it can be time consuming and frustrating to test all of the mechanics and verify them for correctness. Even more so if the values keep getting tweaked on a constant basis throughout the development cycle. How can you keep making sure the data you put into the simulation is processed correctly on a consistent basis?
A solution for this problem is to actually implement a large set of unit tests that are specifically design to check the integrity of you data model. It is almost impossible to write unit tests to determine if the game is fun, but it is relatively straight forward to write tests for the input and output for you data model. Especially using the new Test Running inside of Unity this becomes a trivial task. Using this tool also enables your designers to run tests without programmer intervention. It might even help them with balancing the game.
Also, remember how we recommended you implement your own simulation tick? Doing this effectively enables you to ‘run’ the simulation during tests without the need to run the actual game. If you require your unit test to run the game for 5 consecutive seconds, you can easily run the simulation tick as long as it needs to ‘fill’ those 5 seconds.
5. Transaction System
Of course, it wouldn’t be a tycoon game if it did not involve some form of money or credit system. Usually everything in such a game either creates a cost or returns money back into your pocket. When developing your game, you will need to create a robust system to manage and record transactions for you.
Now, you could (We wouldn’t) implement this in some sort of a blockchain like system… but that is a little bit outside of the scope for this article. Instead, we recommend you to build such a system outside of Unity and try at to stay away from floating point data types at all costs. You game does not need 8 decimals of precision to create an accurate model for currency. Alternatively, you should stick to using fixed point data types.
6. Interface Design
Due to the massive amount of data inside a simulation or management game, it is often hard finding ways to squeeze that data in a insightful overview to the player. Throughout the development of your game, you will often have to iterate on interface designs to make sure that the player can find all the information they need in an intuitive way.
In order to make this as easy as possible, we think it’s best to make use of Unity’s UI system as much as possible. Try to make sure that designers can easily create new version of the interface without needing the help of a programmer. Instead, ask programmers to write reusable components that the designers can work with.
To conclude, we hope these tips have given you some ideas of the challenges involved with creating a tycoon game inside the Unity engine. and how to tackle them. We discussed how it’s best to create a split between data and visitation and how this could also benefit you in combination with unit testing and simulation cycles.