Entry 77 with Unity

It’s time ladies and gentlemen, time for change! Time for a goal change, time for a scope change, time for a game change… literally. I haven’t devoted much time to Uproot in the last few months, almost a year. Let’s be honest — I haven’t done anything. Between work and more work, I’ve had no time or determination to properly finish this. Meanwhile a whole lot of code and art are collecting dust, while the blog and website are collecting spam comments. But enough about the past, let’s focus on the future.

I don’t have to start anew (have mercy), but I can certainly trim and consolidate. I’ve wasted far too long on minor things that aren’t even part of gameplay. They may make for a more polished game, but it is all for naught if there is no game.


But wait, what is thi, Unity? Didn’t I just “port” to MonoGame? Someone who cares might ask why and why Unity in particular (why XNA or MonoGame don’t do it?) For one, I am working in Unity for other projects, so I don’t have the headache of multiple IDEs. Secondly, there are great community resources and many readily available assets and examples. Finally, Unity is commercial, supported on many platforms, updated and unlikely to be phased out any time soon. Subjectively, it’s also fairly straight-forward and let’s me use C#.

Back to basics

Now, Unity isn’t 2D, it’s 3D and doing 2D is basically doing 3D with quads and flat camera. Without too many details, here’s my isometric grass tile:

DevDiary 077 - back to basics - simple tile

And here’s a new mob in that tile:

DevDiary 077 - back to basics - simple mob sprite


Finally, let’s tile the tiles as before:

DevDiary 077 - back to basics - simple tile isometric tiling



Unity is 3D, which means 3D cameras. All above screenshots are orthogonal views (what XNA uses, flat camera, no depth distortion). If I am using Unity, why not something fancy:

DevDiary 077 - isometric tiles from angled perspective camera


BAM! Awesome. With a little fiddling and smart positioning of other sprites, I can achieve some pretty cool pseudo-3D views. All the sprites are 2D. But add a bit depth, a bit parallax, a bit perspective distortion and it will start feeling much more 3D.

One problem though — seams:

DevDiary 077 - seams between isometric tiles on zoom


This isn’t an issue with 1:1 orthogonal camera as everything gets mapped perfectly and I can just use pixel or point filtering. I cannot do this if I am to distort the sprites, in other words, if I rotate and shift the camera, the sprites need proper filtering. Unfortunately, these are isometric tiles and the usual tricks (offset UVs by half a texel or have original sprites with extra border) don’t work for me.

So here’s a fancy solution — render the tiles with orthogonal camera to a separate texture and then render that texture on a quad that is then viewed by a perspective camera:

DevDiary 077 - tile on separate render texture

What this achieves is that the original sprite layout is point filtered and pixel-perfect, and the camera films it that way. No issues. That image is then distorted or viewed under an angle as a whole, so any filtering is applied to the whole image and no longer individual tiles. This makes the seams go away (mostly anyway, but I’m done fiddling with this miniature for days).


I don’t want to remember what nightmare the original border algorithm was, so let’s just say this took an hour to do (hell, I can write border algorithms in sleep now):

DevDiary 077 -random tile border choosing algorithm

Looks right, right?

Anywho, I think this is enough for a post. May be I will shame myself into future updating since I made fancy promises here. Looking back, I share no illusions that this simple TD won’t break any records. In fact, it’s gonna be a miracle if it gets published. I think my goal now is to simply get something out there, go through the process once and then come back with something more… playable. This is not to say Uproot doesn’t have huge potential, it’s just that I don’t think I can realize that potential at this time.

This entry was posted in Uproot DevDiary.

Leave a Reply

Your email address will not be published. Required fields are marked *