Category Archives: Unity

Auto Fire: Technical Debt

As I am gainfully employed, my time working on AutoFire is mostly relegated to mornings before work plus weekends.  I don’t have any pretty pictures for you from this past week because I’ve been ripping out the guts of the game, getting it into a smoother-running and more manageable shape.

You wouldn't believe the number of pictures with stick figures holding up the word "debt" there are.
The internet contains precisely 51,245,721 stick figures holding up the word “debt”.

In programming there is a phenomenon commonly referred to as “technical debt”.  In short, it means if you take shortcuts  and the “easy way” for quick results, you usually pay the price down the road.  Those temporary fixes and band-aids that you applied in lieu of carefully planning and documenting your work gets built upon again and again…  Eventually that foundation of toothpicks and dried spit can’t bear the weight, and you realize that your work cannot be maintained.  You throw up your hands and say “This has to be completely redone!” This is the day your technical debt comes due.

In game development technical debt is common…  Early in a project you want to prototype all the gameplay quickly to give everyone a sense of how something works.  You try things, you iterate on an idea to make it better, you try to “fail quickly”…  You do all those things that the best game companies hold up as their credo, which means you have to focus on speed and agility.  Try that crazy new control scheme, add a strategy component to your FPS, see what all the goats look like with hats, or whatever the team comes up with.  This behavior does not encourage proper architecture, and often involves what a programmer calls “a hack”.

BUUUUUT game making also is a business, and there is always pressure to move forward because the last problem is in the rear-view mirror…  This comes from folks like producers and publishers, but isn’t just about the folks in ties and suits:  a lot of people on the team can get antsy if they don’t see new things on a weekly basis, because morale is everything in a creative endeavor.  Programmers get tremendous pressure to move on to the next big issue, and frequently they will warn the powers that be of the technical debt that is being accrued.

Of course, when the day comes that the debt must be paid off, it will involve days and days (sometimes weeks!) of time when nothing changes… in fact, the goal of this cleanup is that everything should work identically as when you started.  It’s very hard for an outsider to understand…  One day long ago I witnessed a manager straight-up ask “But can’t you just hack the entire game?”  No… not if you want something that won’t fall apart when thousands of eyeballs and eager mouse clicks are set upon it.

Nonetheless, “hack the entire game” is precisely what the 7DRL is about…  You need results now and you don’t apologize for it later.  You’ve got 168 hours to get to the finish line and you don’t care if you trample over every “Write Smarter Code” author who ever was.  And I certainly did that.

It's finally time to ditch the last of those 2D pixel art sprites...
Now I finally have time to ditch the last of those 2D pixel art sprites!

For AutoFire my control and world update system was my cross to bear…  I piled my inputs and the control of my entities in Unity’s “Update” system, where each object gets called every frame.  I cobbled together some bullshit traffic-cop system to move things in the right order, except Unity plays it pretty fast and loose…  There isn’t really a great way to guarantee that, say, the function that tells a car where to go would run before the function that actually moves it.  Frankly, I started to not fully understand how the damn thing worked at all.

I knew the debt was coming due…  Players didn’t always feel their commands were registered.  10% of the time the smooth movement of an entity would inexplicably twitch.  The enemy vehicles just spontaneously stopped working.  But I knew fixing it would be a slog, which is why I procrastinated by working on some pretty terrain last weekend instead of doing what I should have been doing.

When you have to rewrite someone else’s code, you can get pretty grumpy about that person.  But when you have to rewrite your own code, you decide that months-ago you was either an idiot or a complete dick.  “What was I thinking?” gets uttered out loud several times, as well as “What the crap is this?” and the classic “How the hell did this ever work?!?”

But a week later and all is well.  The code to control everything is about 25% of its original size.  Everything is carefully managed.  Your input is now queued up and doled out to your vehicle on demand.  Now I can get back to the fun part of making things blow up.

Ludum Dare 34: Complete… ish?

Over the past 48 hours I’ve been whipping up a silly game for Ludum Dare #34.  Whew, I’m beat!37354-shot0-1450062206The theme was “Growth” (there were two to choose from).  I was kicking around a weird idea about growing your magical influence by traversing ley lines around a map of a real metropolitan area.  You control a fanatic Cthulhu cult who wishes to bring the elder gods into the world.  A classic set of “adventurers” are set against you.

It was created in Unity 5.3.  All art and sound had to be generated in the 48-hour span by the single entrant (me).

You can play the game on a webpage following this link (sorry if Chrome loads more slowly than Firefox):

ClickToPlay

You can also download the standalone PC player by clicking the adventurer: Adventurer

Oculus Rift: Weekend Puttering Part 2

I borrrowed the Oculus from work again this weekend and put just a few hours in…  This time I experimented with setting up targets and creating a mechanic where the player can move slowly to new locations by pointing and right-clicking.  Overall it seemed like a worthwhile experiment…  Actually the motion was some of the best part.  I think perhaps just a constantly orbiting viewpoint could work all right, with maybe a few choices as to where to move next.

The goal is to create motion and control that won’t make my wife sick…  Have yet to put her in it, but it might just work.

Oculus Rift: Weekend Puttering Part 1

My company (Hidden Path) was kind enough to let me borrow one of their Oculus Rift DK2s over the weekend to do some experimentation.

I got it working in Unity pretty quickly, and proceeded to experiment with a stationary camera position with a mouse-aim cursor.  After a couple of experiments, I ended up with a model where the cursor points at a single point in 3D space, manipulated by the mouse.  If the player’s view moves away from the cursor, the cursor gets “dragged” with it.  It felt pretty good and snappy in the end.

I also did a simple dumb character using WASD controls, with motion relative to the viewer (ala Mario). That part was easy and I can see the appeal (although with my test sprite character it’s a bit lacking of course).  It was fun to mess around with!