Category Archives: Unity

Smoother Sailing

Another slow weekend with not a lot to show yet.  I’ve been digging into my simulation model again and working on some of the halting, awkward motion that both my tactical maps and, surprisingly, my overworld maps have had.  I’ve gotten a few complaints about it, and I couldn’t deny that it was really harming the feeling of speed I wanted to maintain.

A couple weeks ago I revised my input system so the player could queue up movements and move many squares quickly.  However, the player was not able to move that smoothly because the system always gave the rest of the world a chance to move before processing the next player action.  However, this happens even if there is nobody to move (such as when the player is going very fast and executes multiple moves per enemy turn), and even if there were no enemies at all (such as in the overworld)!

This was a useful thing to iron out, and I created a system where the game will stretch out executing any turn based on the longest time given it.  This defaults to 0.2, but with this, the player could execute a full, second-long super attack if he wanted.  Also, if no enemies are on screen, their moves are shorted or eliminated if they are far outside of the player’s awareness.  This gives me a lot more flexibility.

I also have turned into a bit of a Unity Asset Store addict.  I found some great music, vehicle models, terrain textures and even some more dang rocks…  it’s rather shocking how hard it is to find rocks that look good and fit with the rest of your stuff.  Looking forward to the next thing on my list, which is to create “templates”, or groups of objects to use in level generation.  Should be fun!

Auto Fire: Skid Marks

After a couple of evenings over the last couple days, I got skid marks working fairly well.  I had considered it a fluff component, but I also knew in my gut that skid marks could fairly easily show the player where a vehicle came from and whether it is under control or not.

Drawing arbitrary skid marks on the fly!

Generating mesh polygons on the fly in Unity was a new experience, but it wasn’t so bad.  The odd thing is that I spent an unnecessary amount of time trolling the docs and forums for info on supporting quads, and whether I’d have to define things in strips and fans and all that.  Instead Unity just asked for every triangle defined individually, and shared edges were not even an option.  I guess it’s been a long time since I had to deal with individual polygons, and the graphics layer has become just that much more sophisticated.  Does that make me a 90’s Voodoo/TNT relic?

Besides, I’m dealing with maybe 50-100 polygons here, so I’m hardly taxing the system…

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!