Tic Toc Games is a service developer with an experienced team of artists, designers, programmers and production managers, all rewarded for their work on interactive products. They want their players to love the games while they enjoy them, to think about them even when they are not playing, to share their enthusiasm with their friends and play them again and again. Tic Toc Games uses Unity since they started creating games in 2011.
Like any video game company, Tic Toc always looks for new ways to get better performance with its code and, at the same time, iterate faster when designing. Garth Smith, chief of Tic Toc programming, says it in a more elegant way: “We need to make better games faster.” He is a former Unity user, and considers that some of the main new functions of Unity 2018.x are very powerful.
With several major ingenuity games pending for 2019, which include a Match 3 and a Collapse, Smith asked his team to make use of the ECS in particular. “ESC works with a completely different coding mode than people are used to. Data-oriented programming is something that is usually taught in classrooms, so it is a great paradigm shift. Even for us, we had a little fear of starting with something new, “said Smith. However, what they achieved with ECS ended up convincing them.
ECS replaces object-oriented programming with data-oriented programming, as it is more appropriate for many parts of game applications. It decouples the processing data, eliminating a huge amount of scattered data, which allows real multiprocessing since events do not need to be processed sequentially.
For example, two entities could be a bullet and a player, each with references to different attributes such as position, appearance and health data. Entities and attributes are simple data, with no associated functionalities. The system applies a function to an entity, such as a movement system to a bullet or an appearance system to a player. This separation of data and functions allows Unity to create jobs that can be processed in parallel in multiple cores. According to Mike Geig, world leader in content marketing at Unity, “Once the system is understood, everything becomes very easy.”
The benefits of using ECS are significant. Simply because of the way data is organized, it is easier to write optimized codes. Hence the motto, ” Default performance . Some of the doors that ECS opened showed us how to make better algorithms,” Smith added. In addition, the ECS code is highly reusable, archetypes (unique entities) are compiled in memory and, perhaps most importantly, ECS can take advantage of the increasing number of processor cores. Currently, the most common processors have between 4 and 6 physical cores and between 8 and 12 logical cores, while the most “fanatic” processors have 16 physical cores and 32 logical cores. Most are never used, but DOTS takes advantage of them all.
Look at the 5-part Presentation of the entity component system (ECS) and the C # job system .
Join the C # job system
Combining the computer-oriented ECS code with the Unity C # job system allowed Tic Toc to take more and more advantage of multi-core processing and multiprocessing. Writing a secure thread code is difficult because of the execution conditions (threads that run in an unexpected order and cause unexpected results) add restrictions, and the constant change of context is ineffective.
But the work system handles all of the above, and allows Tic Toc developers to focus on the specific code of the game. Smith explained: “A job allows us to run our systems in multiple threads and use different cores of a CPU, processes that we used to consider quite complicated. The ECS and the job system allows us to make use of almost 100% of the other cores, which is incredibly effective. ”
The Burst compiler speaks directly to the hardware
The new Burst compiler is a LLVM-based mathematical compilation technology that performs C # jobs and produces a highly optimized machine code for the particular capabilities of the target platform. For Tic Toc, that meant that Smith and his team did not have to waste time relearning and machining complex low-level codes to solve performance problems.
“With the Burst compiler, we were able to guess about what we do with the ECS, and that speeds up the work. We found that some loops increased around 30x, especially when they occurred many times during a frame,” Smith said.
The team discovered that when large systems interact, the Burst compiler eliminates a significant amount of interaction problems that normally should have been resolved during quality control. “With the Burst compiler, you have the advantage of a manual assembly code for multiple platforms, without all the hard work,” Smith added.
Tips from other studies on DOTS
The transition from Tic Toc to a data-oriented approach at the beginning was tentative, but in turn it was an interesting challenge. “Once I got the trick to ECS, everything started to be easier. I think at this point, everyone in the studio already understands it, and they love it. Probably, we will play all our next games with the ECS,” Smith said.
He also has good advice for other studies. “It is not advisable to enter fully with ECS at the beginning. It can be incorporated gradually, and even when used to do small things an improvement in performance is already noticeable, especially thanks to the reuse of codes.”
In addition, Smith recommends trying a prototype project before launching into full production. “Try something simple like a game jam, a Tetris, an online three, no matter which one; just complete a game at ECS before putting your whole team to produce with art and all that. You’ll learn a lot with your first test “.
Finally, Smith is eager for the reaction of Tic Toc players. “You will surely notice a different feeling and performance with our new 60fps games, no matter what is happening on the screen. I know you will enjoy the improved playability and responsiveness!”