Technical Post Mortem : Building a game with Unity3D Engine

Hello,

I wrote this 3 months ago and just read-proof it today.
So I share it now, maybe some people will find it interesting to see all the issues I fought with while building my game with Unity… :slight_smile:

The Fall of the Dungeon Guardians | Technical Post Mortem : Building a game with Unity3D Engine


A tough Boss !

Ok, I’m still not ready to write a full post-mortem, but after seeing this thread “Unity is broken” – What are people referring to? , it made me want to write a list of all the technical issues I got creating Dungeon Guardians, most of them being tightly tied to using Unity3D (real name = Unity Engine ; Domain name = Unity3D.com ).

Before to go further, I think I need to make this very clear : Unity is a great engine and without it Dungeon Guardians would either not exist at all, or look way less good than it does ; and having used it made me save a lot more time than it made me lose.

Thus said, I have built my game engine using the minimal stuff possible from Unity, and every part I used had a least one really annoying issue, if not several.

Let’s start with a painful task that almost no one can do without : debugging
Conditional Break in the MonoDevelop Debugger never worked. It makes debugging much tedious as I had to add some lines of code and recompile everything every time I need to check a special case. Later on I switched to Visual Studio and its debugger which was technically working, but often terribly slowly, so not much more usable actually. Though this last point is likely the wrong of C#, not Unity.

To stay with the debugger, pressing the “Play” button while the Debugger is attached makes Unity stall for 20-30 seconds instead of starting in less than 2 seconds. After that, it executes normally.

Moreover, Live recompiling (ie: changing the C# scripts with the game running) isn’t practical and thus I never got it working. This is the thing I miss the most from developing in C++.

Let’s continue with some isolated issues
Physics engine handles really badly small fast moving objects ; I had to use & tune this to fix the issue : http://wiki.unity3d.com/index.php?title=DontGoThroughThings .

The FPS counter in the stats doesn’t actually count the FPS ; it estimates them in the most idiotic possible way and thus is completely useless and misleading.

There’s no built-in decal shader, nor shadow-receiving transparent shader ; so for putting spider webs on my wall, I had to grab an user-made shader .

GL rendering stops to work in OnGUI after an alt-tab (ie: switching to another application), but it works again after a couple of alt-enter (ie: alternating between fullscreen & windowed mode). There’s no fix nor bypass for that. This is one of the rare bugs left in the game.

There’s no documentation on how to handle a lot of sound sources. The sound parameters would let you think it’s automatically handled, but it isn’t. Fortunately, I have been able to just cull the sound sources with my custom-made occlusion system for the rendering.

And now for the big part : animation & importation
Legacy Animation system was duplicating the animation clips assigned at realtime, instead of referencing them, which leads to a gargantuan amount of wasted memory (more than 1GB!). I had to swap to the new Mecanim animation system which was severely feature limited. Fortunately, the possibility to change the speed of the animation per layer came with Unity 5.1. Unfortunately, this version made the legacy immediate mode GUI way too bright in editor more (but luckily not for the built game). 5.2 fixed that issue but destroyed the animation system, making everything jerking around when using multi-layers. 5.2.1 fixed that but not completely, and 5.2.2 didn’t change anything, thus final version of Dungeon Guardians is built with 5.1.3p3 and I kept on burning my eyes every time I launched the game in editor mode (which was all the time till recently).

Disabling & re-enabling the Mecanim component of an object removes the current playing animation clip instead of only pausing it ; ie: it completely empties and then resets the internal state of the animation. It brought me a lot of issues and it has been very hard to figure out a solution. But the hardest past has been to understand that behavior, because it is not documented. I have requested more than 1 year ago to be added to the documentation, and as of today, it’s still not there .

Still in the animation department, it is not possible to select multiple animation clips and change their import options all at once. You have to do it for each clip, which can have near of 10 parameters, 1 by 1 ! There are hundred of animations in Dungeon Guardians, I lost hours if not days doing a stupid grunt work that should have taken less than a hour…!

To go with the resource management, the texture re-sizing on importation is done with a very simple algorithm which has the double-perk of being both too aliased and losing contrast. The 1st one happens when resizing to a much smaller size and the 2nd one when dividing the size by only 2 or 4. Using “Bucibic Sharper” with Photoshop gives a much better result. It means I had to do an awful lot of grunt work to get the best of all the HD textures I had, instead of relying on the built-in scaler.

And now, the true Unity specialty : Half-cooked Features
It’s really the plague of Unity. They’re in a race to always add more & more features, while regularly never really finishing the existing ones and letting them with blatant missing possibilities.

The most patent example is the “new” animation system Mecamin (it was released with Unity 4 in July 2013), as explained above, which needed nearly 2 years to get a layer & clip based speed setting. It’s something that a lot of games need. Think for example at an adaptable run speed animation for the legs and a defined speed for a fire animation for the torso.

In the same vein, the Unity Input doesn’t allow to be set in-game. It’s even not possible to know what key is assigned to an input ! Which means any developer wanting to offer in-game configurable input (instead of the default Unity launcher setup) has to redo the Input from the ground up, as I did for DG !

In bonus, the text input field doesn’t work on Linux. It may or may have not be fixed in latest version of Unity, but as I couldn’t use it (see above), it meant I had to re-write my own (which doesn’t support Ctrl+V & stuff like that) : you’d be surprised at how much people actually want to enter the name of their choice for their character in an RPG, even if they use Linux…!

The “new” particle system, Shuriken, released in February 2012 can’t use a skinned mesh (ie: an enemy) as source for its particles ! It has been fixed in Unity 5.3, released at end of December, nearly 4 years later. For DG, I had to use an external add-on (and yup, I had to paid for it).

Conclusion
I skipped a good bunch of issues which were also annoying but have been fixed before releasing the game, and that didn’t require extra work on my part before that. I also skipped a dozen of little issues which were more or less trivial to fix once found.

I also had several undocumented changes of behaviors, some really strange.

All in all, I feel lucky I had a version that let me built the full game without any major bugs nor important missing features, but I’d have liked to make it without the GL render & Text Input on Linux issues. Maybe someday I’ll try to update to Unity 5.3 and check if it doesn’t break anymore my animations, without breaking some other new stuff.

For now, I think I’ll be still using Unity for my future games, although for the very next one, I’ll still use my old custom framework so I’ll be able to use my old game engine without porting it to C# right away.

And to end on a positive note on Unity, it has been really fast & pleasant to be able to build all versions (Windows / Mac / Linux all for Steam and for Mana Games, and the Mac AppStore one), while it was really cumbersome with my old homemade framework.

16 Likes

Great set of notes.

Also congrats on the game. With 150 reviews on steam very positive (and some good press reviews!) it seems like a well made game!

You have users with over 150 hours of play time, how much content did you include?!

Thanks for the write up.

Seems like you made it through! And most of the end users won’t have any idea, what had to be done behind the scenes to make it happen!

“There’s no built-in decal shader, nor shadow-receiving transparent shader” - first one I don’t know about, but Standard shader’s cutout mode receives shadows?

“multiple animation clips and change their import options” - Couldn’t this be handled with AssetPostProcessor? Haven’t touched it yet, but I have been reading about it and it.

Congrats on your release, and thanks for taking the time to write the technical post-mortem.

I think you hit the nail on the head on several points.

I agree especially with the point that Unity needs to fully implement all the half-implemented features out there.

3 Likes

Well done finishing a game, and a very good looking one to boot! Thank’s so much for taking the time to make this write-up, it’s important to point out the issues as you have, in a respectful and honest way. And let me tell you something, I’ve been working with Unity for 5 years now, and I can tell you that we ran into just about every issue you did and a few others.

Speaking of which, I’m really interested to know how you guys approached in-game quality settings. Unity’s quality settings are currently pretty whacked in that certain options cannot be changed by themselves, meaning we have to create dozens of “fake” quality setting profiles to allow for things like setting the quality of shadows. Did you have to do something similar for you in-game menus?

1 Like

I didn’t know it was so much issues. Will these be fixed ?

@frosted ,
thanks !
The game has 20 levels, each of them being in average a bit bigger than the usual dungeon crawler level (eg: Grimrock or Dungeon Master). Each level requires from 2 to 4 hours to complete, depending the chosen difficulty and the will to find all secrets, but some people get crazy with completion, and/or do a 2nd run with a different party, so it can last much longer.
All in all, it’s probably one of the biggest handmade single dungeon you could find in a game.

@eses ,
the cutout shaders receive shadow, but not the transparent ones (ie: transparency percent determined by the alpha channel). Shadows can’t work correctly on them, except when they are decal textures, like spider webs on walls, bullet holes, etc…

AssetPostProcessor didn’t handle the animation parameters.

@McMayhem ,
quality wise, I aimed so all gamer 3D GPUs of the past 6 years would be able to run the game in Fantastic, Beautiful or Good qualities. In that way, it didn’t make much sense to separate the different parameters of the quality settings, so I just let the user choose at start or in-game the global quality setting.
But the things that matter for taste (ie: motion blur, FXAA, Bloom) got their own separate toggle.

@zenGarden ,
most issues left are by design (or absence of), so there’s low chance they’ll be fixed anytime soon. The ones in legacy parts of Unity (eg: old animation system, OnGUI) will likely never get fixed.
Unity has planned to do a complete rehaul of the input system, though, so in-game configurable inputs may arrive soon.
For the GL bug, I reported it there a couple of months ago, but as it was not flagged as important it might take many months or even years to get fixed : Unity Issue Tracker - GL.LINES disappear on window resize if used in OnGUI w/ Deferred render path .

1 Like

Wonder if Unity will make a whole playable AAA scene for Unity 6 so they can finally get a taste on how a whole game comes together and not just create 25028502 features that break the second they try working together.

Meanwhile, Epic is making a whole bunch of games, and implementing all of the PROVEN features in the engine. Unity releases Blacksmith and not only is it a cinematic but most of its techniques are specifically tailored for it (and never being introduced in the main branch of the engine as the evidence you need). Then you have things like The Butterfly Effect implementing APEX… but the demo having no impact whatsoever on the development of the engine.

And we have The Forest and Firewatch. Graphical showcases, stuttering like crazy on the craziest of setups even when they are full of competent and qualified programmers with experience delivering AAA games. Even Ori and the Blind Forest, a 2D game, stuttering when transitioning between areas.

But its okay… keep working in IL2CPP even though it often sounds like a convenient excuse to halt the engine development.

2 Likes

I agree legacy is past system, no more valid in Unity 5.

That’s sad.
This is why Unity should bring other parts open source soon , to have people able fix issues like that and submit corrections to Unity to incorporate them.
This is why Unreal 4 and CryEngine will always get faster and more bugs corrections for small things.

Anyway great game.

2 Likes

The older UI system isn’t completely legacy. It’s powering the editor and any extensions made for it.

1 Like

Also, the legacy animation system still has a lot of use cases where it’s faster than mecanim.

Like what for example ?

" @eses ,
the cutout shaders receive shadow, but not the transparent ones (ie: transparency percent determined by the alpha channel). Shadows can’t work correctly on them, except when they are decal textures, like spider webs on walls, bullet holes, etc…
AssetPostProcessor didn’t handle the animation parameters."

@manutoo

Transparency - Well ok, in my books cutout ( = alpha test) is as valid “transparency” as any method (alpha blending), so transparency does work, but is limited to certain techniques. As you didn’t mention it, I thought to mention it.

AssetPostProcessor. Now that you mention it, not completely true. I checked my notes. I’m not sure what you are / were doing, but you can definitely do change to animation clips; set start, end, name, take name and so on? What did you try to achieve? Just now tested it and basic stuff works just fine it seems…

There are other issues too. I’m finding this a lot as I work on my current game.

1 Like

@eses ,
the exact issue => Any way to select multiple animation clips in a .FBX to change their settings in batch ? - Unity Engine - Unity Discussions . It wasn’t actually an issue that could be solved through AssetPostProcessor (memory is a bit blur after 1 year and half :wink: ).

“Moreover, Live recompiling (ie: changing the C# scripts with the game running) isn’t practical and thus I never got it working. This is the thing I miss the most from developing in C++.”

It worked a few times, and then at other times could completely crash unity, soon stopped me bothering… now I just wonder if one person out of all the employees at Unity is capable of actually bother to start filling up the options screen with ‘actual’ options… like to disable it from recompiling saved changes until the play mode has been stopped.

“Physics engine handles really badly small fast moving objects”

Yeh noticed that, just using things like quad planes with collision on would often have other colliding objects pass right through, switching those quad planes to cube meshes worked better… plenty of other issues, its a playground of bugs and performance issues with no support for having finer control over substeps on a per object basis.

ugui … doesn’t have any guiskin feature, and still no built in nested prefab support, so working with it seems to become more of hassle than its worth if you want customize it away from the ugly default theme and when your gui starts getting more complex, suddenly oh shit what a mess this is to work with. And building a gui within the scene view, its just dumb when they don’t even provide proper methods for not selecting other scene view objects in the background that aren’t gui components… yknow other software/engines provide a dedicated designer window for gui placement with things like an actual effing built in grid for snapping and alignment. Thanks to the assets devs that have done something to alleviate such a mess to some extent. I kinda like ongui for programmatically being able to do things and just utilizing gui skin probably been a little better now, but yeh it sucks aswel…no perfect system still. Then most of the most default components for ugui are kinda basic at best, and need more work to improve them or decent ones simply don’t exist. The ui extension project at bitbucket improve things a little, but its still rough around the edges… I just want to say bitbucket as website sucks for opensource projects that want contributors… its fine for private repositories… where maybe you just dump your project on it, but never ever bother going to the website because looks like it was designed by morons.

And finally I think I know what the ‘u’ at the front of ugui/unet means… its an insider joke for… ‘unfinished’ :smile: … as the progress on improving or complementing those features with other needed features since they’ve been out has been slow, though I’ve not really bothered with unet much as I was waiting to see phase2 and still waiting.

Cutout is not transparency.

Cutout is alpha-testing.
Transparency is alpha-blending.

In unity engine it is impossible to make engine cast shadows onto transparent object, especially if said object is outdoors.

2 Likes

@neginfinity -Both make pixels from textured faces look invisible or partially invisible. They are both meant to simulate partial transparency of faces, where alpha test is more efficient on many platforms (not all AFAIK), there is no such thing as real transparency or incorrect transparency IMO! I don’t know what this wordplay helps…

If we are going to be semantic then technically alpha cutouts are transparency while alpha blending is transparency with translucency.

@HemiMG_1 - Then again, isn’t translucency also a bit different feature of semi transparent materials, where scattering and colorization / filtering can happen? At least on 3d software side, commonly translucency isn’t the same as transparency. There’s no need to be semantic.