Last year, when I started working here, one of my first projects was a drastic enhancement of the player animations in Garry’s Mod, which runs on Source. It’s something I had always hated when playing online; everything was stiff, with weird blending everywhere, and a bunch of other small niggles that added up to be something I disliked looking at. I thought that after all, for a game primarily focused on multiplayer, other people should move in a more visually appealing way. Dozens of Gmod updates later, the anims look far better, they picked up some of Valve’s latest bells and whistles, and I keep them up-to-date with community requests.

Well, not lately, since I’ve been busy with Rust — speaking of which…

Last week, Pat (the man wizard behind the low-level programming dark magic in Rust) and I took a stab at implementing the player model. The model itself was the easy part: Unity, as a toolset, definitely got that process right. Three clicks and you’re done. As for the animations, it’s something else entirely… you’ve got a choice between the legacy animation system, and the new one in Unity 4, Mecanim. From what the other programming wizards told me, Mecanim is not an option right now, for several reasons: incompatibility with existing systems, client/server load…

So we’re stuck with Unity’s legacy animation system, and it’s missing many features I’d consider crucial. I seriously didn’t believe I would ever write this sentence, but here goes: I miss the Source engine’s QC system!

People often talk about Source’s artist pipeline in very negative terms: outdated, complicated, buggy, quirky, etc. In my experience, it’s really “quirky” that’s the most fitting word, just like everything else in Source. Once you’ve learned the quirks, you can do pretty much whatever you want, and fast. Said quirks are often undocumented and require manual experimentation and research to figure out… but it’s good practice.

For instance, it took me eight months to fully figure out some obscure macros that are only very quickly explained in the TF2 source code — they’re actually macros inside of macros inside of a macro… it gets complicated fast. However, once an artist has learned all those quirks, they can do everything within QCs. This includes a very wide variety of flags to assign specific animations to player code, as well as how it’s triggered, if it triggers something else, how it should blend, etc. All of this isn’t in Unity for the artist, and has to either be written in the player manager code directly… or written from scratch because similar features don’t actually exist!

Here are some examples from Source I can think about, off the top of my head:

  • World space blending. If I want to blend a pose on top of the walk/run animations, so it looks like you’re actually holding the hatchet/gun/etc, I have two options: either I do this directly in 3ds Max (but this is not ideal for modularity or memory at all), or I freeze all motion on the pelvis and up, so that it’s effectively T-posed on everything except the legs. Then an additive animation comes to set the pose. This is what makes things look very stiff right now. With world space blending in Source, you can just fade in a pose, and since it’s not additive nor blended in local space, the pose will always stick to what you have, no matter what’s on other bones. If you have an arm/gun pointing forward, it will always point in the exact same direction, no matter whether the animation underneath has the torso on the side, laying down, bending up or sideways…
  • Inverse kinematics on arms and feet. This is a big deal in the Gmod player animation set (especially since I strive to support both male and female sets as much as possible) — at all times, feet IK is involved, and hand IK is involved for any two-handed weapons.
  • Easily accessible weightlists. Weightlists are how you specify that you want a given animation to only affect specific bones, and by how much. So for an upper body pose, you would gradually fade it up the spine, and it would have full weighting over the arms. This goes hand in hand with world space blending.
  • Easily accessible layers. In the same vein. This is one of the things Source’s QC does best; it has a wide array of available commands so you can bend the system your way. For Gmod, I wrote a macro that takes an animation, uses its pelvis motion as additive (but I can instantly put in a mix of absolute/additive by changing the referenced weightlist), and uses the spine as absolute. Then I put my frame numbers in for fading in and out. This makes weapon gestures like attacking or reloading super easy to implement. All those commands have options for blending (including S-splines), you can blend their IK rules separately if you want, or you can disable IK on this specific gesture, on this specific limb… etc, etc etc. It’s all extremely flexible.
  • Additive animations that aren’t self-referential. This is where the advantages of QC really shine. In Unity, if you want an animation to be additive/delta, it uses its first frame as reference for the additiveness. In Source, you can specify literally any frame of any file as reference.

In general, anything that doesn’t force you to go through a programmer to implement your art assets is good! QCs do look (and feel) like programmation at first sight, but once you get the hang of it, you do what you want on your own:  it’s great freedom, and it’s super flexible. The learning curve is steep, but boy is it worth it. There’s a good amount of animations in Gmod that are literally piecing bits from one, bits from another, and bits from yet another one together to form something that looks way different, and that’s done entirely in QC. That’s how flexible it is.

And much to my dismay, it’s night and day with Unity so far.

In the end, the current player model in Rust is pretty stiff and doesn’t move very well — but as visually displeasing as it may be, it works! And, all things considered, for an alpha, it’s pretty good — but once we want to have better animations we’ll have to rework a good chunk of the system underneath this. And right now, it’s better to fix more important things… or add more cool toys!

(like bows with arrows.)