https://youtu.be/I860nYbCVyk
It’s one thing to make a big, complicated eco-simulation game like WolfQuest 3. It’s another thing to make it run fast enough to play smoothly on a wide range of computers. So lately, we’ve been spending time on optimization: analyzing the performance (speed) of each element of code and graphics and figuring out ways to make it perform better. This week we’ll look at three things we’ve been optimizing.
Games use both the CPU (Central Processing Unit) and GPU (Graphics Processing Unit), and using Unity’s built-in Profiler, we can analyze the load on both CPU and GPU in great detail. Here are a few things our team has been doing, as explained by two of our amazing developers, Tommi and Nick, and then myself, Dave/loboLoco.
Tommi on Animals
For the last couple of weeks I've been neck deep in Unity's Profiler feature, which breaks down what's happening in the game frame-by-frame, operation-by-operation (broadly speaking). The main issue has been the spikes caused by spawning animals as you get close to the flocks. So far, I've been prioritizing the ease of editing the animals over the speed of spawning, so there was a lot of expensive calls that add new scripts onto them every time they spawn etc. (so I don't have to manually edit every type of animal every time I add or remove scripts). But now I employed the following strategies to reduce the time (without making editing too much harder):
1) Pooling: This means that whenever an animal is despawned, we don't destroy it but instead hide it and put it in a "pool" from where it can be reactivated later. This is much quicker than creating a whole new animal. We can also create a few animals into the pool during the initial load so even the first spawns will be quicker.
2) Baking: I created a system that automatically adds all those different scripts on the animal in the editor so they don't have to be added during the game. This is a bit risky since if the system has a bug the animal setup may get out of alignment when I later make changes, but I'm reasonably confident it's all solid.
3) Plain old optimizing: There were a few places where I was doing unnecessary calculations, or where shortcuts could be created.
In addition to these spikes, I've also been trimming the CPU consumption that happens every frame. The main suspects here have been floating scents and animal AI / physics. This mainly involves:
1) Considering if we really need to do a thing.
2) Considering if we really need to do a thing every frame.
3) If we need to do something frequently, try to at least spread that burden even over different frames to avoid spikes.
It's been a challenge trimming the CPU cycles, while keeping all the cool things we want to do and also not making the codebase full of shortcuts and hacks, as that can create new bugs. But it's coming along, step by step…

Nick on Pathfinding
With Wolfquest 3.0's greatly increased map size comes new technical challenges, one of which was Pathfinding (wayfinding): the system that allows our animals to move through the landscape in a believable manner. More obstacles to avoid means more computation, which means we had to develop whole new techniques to speed up the process and keep the frame rate high.
To this effect, we developed a new system of pathfinding. It is similar, in theory, to the 'Level of Detail' Systems used by our rendering pipeline to allow the highly granular (and computationally intensive) obstacle avoidance near the animal, and high level "Fuzzy" Path Generation that is done much more cheaply.
To give an example, let's say the highest detail map in this system has 30,000 Nodes. That means the computer has to search across all of those nodes multiple times to discover the most correct path from point A to point B. 30,000 isn't that much to a computer but if it has to do this maybe 100 times, suddenly that 30,000 Nodes becomes 3,000,000 Nodes…quite a bit larger! So, instead of searching those 30,000 Nodes, we can instead use a lower level of detail. Let's say the next map down only has 5,000 Nodes. Then, if we have to do that 100 times, we're only looking at 50,000 nodes.
For long distance pathfinding, we use a lower level of detail, and only use the highest level when we need to pathfind a very short distance, perhaps as short as 100 meters or so. This means more computational power can be devoted to rendering gorgeous landscapes, and less to more invisible gameplay functions.
Dave on Graphics
With the original version of WolfQuest, and again for WQ 2.7, we developed the graphics to run decently (30 fps) on a mid-range computer. That made optimization relatively easy, but it also limited how good the graphics could be on more powerful gaming computers. For WQ3, we’ve been focused on creating the most realistic and immersive 3D environment that we can, using a Windows gaming computer with Nvidia 1060 GPU as our development rigs. So now we have to find ways to optimize the graphics to run on weaker computers, and as necessary, reduce the fidelity of the graphics for lower quality levels. We’re using some state-of-the-art tools for terrain and vegetation rendering, but even so, the dense forests of Yellowstone pose major challenges for optimization. Unlike most games, we can’t design our forests with performance in mind. Further complicating the challenge is the fact that we’ve got a dynamic day/night cycle, which means we can’t “bake” the lighting and shadows into textures, which gives a huge performance boost. Instead, the game has to render shadows on every frame, since the sun moves slightly from one frame to the next. So we have our work cut out for us. We’ve been making progress, but it’s too soon to say what the final system requirements will be for computers and mobile devices.
_________
WolfQuest is available for Mac, Windows, iPhone, iPad, Android & Kindle. So yes, WolfQuest 3 will be available for mobile phones and tablets...at least some of them, and/or in some form. Bigger maps and more animals may be too much for mobile devices with limited RAM memory. We'll do our best, but there's a good chance that some mobile devices won't be able to get it, and/or we will have a simpler version of it for some mobile devices.
For the PC/Mac version, our goal is any computer that can run the current game can run WolfQuest: Anniversary Edition. We are adding more quality levels so we can boost the visual quality much further than it is now, but we will do our very best to make the game run decently on older computers. However, since we are adding so much to the game (bigger maps, better graphics, more animals), we can’t yet say how well we can attain this goal. We don’t know exactly how much storage WolfQuest: Anniversary Edition will require, but probably about 5 GB.