Blog 643: 18-Gun Salute

A game with only a single type of enemy is not much of a game. Well, okay, actually, Unreal Tournament technically gets away with it (the differences are visual only, though they are heavily parameterised), but I’m not operating on that level — so I want there to be as big a variety of mechs as I can make.

But up until recently, I only had one character: the Delta mech. In order to stress my systems a little bit and help work out the kinks, I decided that the next mech had to be the monstrous three-legged Alpha…

No Kill Like Overkill

I’m still heavily entrenched in Milkshape 3D and I see no reason to change. It works perfectly for the level of art I’m comfortable with, and despite its age it still has an exporter for a format that Unity understands.

Making a whole character and animating it in Milkshape 3D is pretty easy. For something like Warcraft III, you’d just export it there and then, fiddle with a few things in Notepad and it’s done.

Unfortunately I chose to make characters a little more complicated for my game. My characters are not singular, unified models — they are made up of many discrete chunks. Chunks that I have to manually separate, position correctly relatively to their attachment points, and export. The advantage is that I can swap chunks around in-game, giving me the opportunity for a wealth of variations on each vehicle. The disadvantage is that… Well, the Alpha has about sixteen chunks.

The last iteration of the Alpha only had 8 guns and even the original only had 10. I've only got myself the blame.

The last iteration of the Alpha only had 8 guns and even the original only had 10. I’ve only got myself the blame.

It could have been even more than sixteen chunks, but luckily several of them can be used on both the left and right sides of the model. Symmetry, ho!

Once exported, though, each chunk still has to be imported into Unity. Since they’re not animated that is pretty easy, but they require further preparation before they can actually be used. Each model must be turned into a UnitChunk prefab, and each one needs a Wreck version too. This is how I do those lovely death explosions — when a unit dies, each of the unit’s chunks replaces itself with its wrecked version and some explosive force is applied to the new piece.

This is all a very manual process, though this could perhaps be automated. Unity allows you to write editor plugins in the same way as you write your actual game scripts, and I’ve seen stuff for generating prefabs — since each chunk/wreck combination is just the same two game object heirarchies set to a different mesh, it will hopefully be possible to write a script to spin through all the imported models and spit out useful UnitChunks.

The biggest disadvantage of all this is that the unit can't actually exist until run-time. Did I strap a thigh chunk to an arm? Who knows!

The biggest disadvantage of all this is that the unit can’t actually exist until run-time. Did I strap a thigh chunk to an arm? Who knows!

So once all the material is in-engine, I have to tell my scripts how to build the mech. Mechanically, a unit is composed of two parts at this point, a core and a turret. These are the invisible animated skeletons onto which the chunks are placed to create the unit.

My unit template system started off life as a key/value pair text file, with an attachment point name matched to the name of a chunk type. When I started looking into varying materials as well as meshes, though, this became untenable — I want more input parameters for a prefab chunk than just its name.

As is the fashion of the day, I turned to JSON. There are many JSON parsing scripts around Unityland, so I grabbed a self-contained C# script and started rewiring.

JSON and the Argonauts

JSON and the Argonauts

Of course the unit templates are all constructed by hand at this point, but I can definitely automate that one day. Templates actually have a parent/child relationship system so that one unit can inherit from another and override its settings — that’s how I do the Deltas you’ve seen in my previous videos that have different cabins and camouflages. The Root Delta has the immutable game-mechanical noodles, while the children assign the chunks and their colour schemes.

The final piece of the puzzle is equipment. Luckily I designed the Alpha explicitly to fit the same weapon sockets as the Delta. I’m all about modularity, after all, and it means I have less overall models to juggle. Every time I make a new weapon that fits the same hole, I don’t have to redesign it five times for five different mechs.

Boom!

Boom!

What’s interesting about the Alpha in action? Because it’s much taller than other units, it’s more difficult to aim its guns — you can’t just face a target and start firing, like the Delta, or your projectiles will go over their heads. You really do have to mouse-over the target to lock on, so the guns pivot down a little; this means you can’t lead the target either. On the flip side, if you are hit by the 18-shell barrage you are almost definitely dead, so this will make the Alpha conveniently fallible in a simulated way rather than a cheaty way.

Also, simultaneously launching 18 identical projectiles looks pretty crap. Although I already had some very light spread/inaccuracy mechanics, these weren’t quite enough — I’ve had to rework the trails so they vary in opacity, and varied the lifespan and velocity of each shell too. That makes things look a little nicer.

Finally, the Alpha cannot run and it can’t jump much either. This has naturally ruined all my bot programming, which relies on characters being able to jump fairly long distances. I will need to parameterise my raycasts a little more carefully, and allow for bots that won’t jump at all. Or I could just build a proper level that doesn’t include a whole heap of random blockages and pitfalls so I can brush this problem under the carpet for another few months.

Advertisements

2 thoughts on “Blog 643: 18-Gun Salute

  1. Maybe you hit this point personally long ago, but that is the first video I’ve seen from your project that would give me joy in a “Hey, this works and it’s fun to play against an opponent” way. (As opposed to a graphical or mechanical victory, like “Hey, I made an animated mech model and it can jump between levels of terrain and it looks convincing.”) Congrats! I hope you enjoy playtesting from here on more than before!

    Like

    • Hehehe, no, I’d say I still haven’t actually hit that point yet! I still need to do ammunition, armour, pickups… So much still to go before I get to minimum viable game stage, and then I will have to make an actual level.

      Like

And you tell me...

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s