Part 3 of the breakdown of my recent Half-Life 2 Scanner scene.
And now for animation! Also known as “Geoff stumbling around blindly for a week when he really should have watched some UE4 animation tutorials”.
So, erm, feel free to use this as a guide on how *not* to approach making an object float down a hallway…
Down the garden path
Early on, I was trying to work out if I wanted to just animate the whole thing from start to finish in Modo, or do something a little more systemic.
For the sake of trying something different, I settled on having the main movement down the tunnel, rotation of the centre wheel, tail and little flippy bits (technical term) through blueprints, and then blend in a few hand animated bits.
There are three main blueprints that do the work: the Scanner blueprint, the Scanner Path blueprint, and the Scanner Attract Point blueprint.
The division of labour between these things ended up being pretty arbitrary, but the initial idea was that an Attract Point can start playing an animation on the Scanner when it reaches the point, and can also modify the max speed of the Scanner when leaving the point.
Here are the parameters that each point has:
So when the Scanner reaches an attract point, it can pause for a while (I use this time to play an animation, generally). The animation doesn’t start when the scanner reaches the point though, it actually starts at a certain percentage of distance along the previous spline segment leading up to this point.
There is also a blend in and out time for the animation, to give transition from the manually animated idle.
The animation blueprint itself does very little:
Down the bottom left is the Idle animation that happily ticks away all the time, and that blends with an override animation, which is what the Attract Points set.
Each of the rotators are driven by procedural animation on the Scanner blueprint, which I’ll show in a bit.
Improvements in hindsight
The Idle / Override blending part of this is definitely something I would change in hindsight, because blending in and out of the idle is a mess: the scanner could be on an up or down point when I start.
There’s a few ways I could deal with it, including just changing the up and down sine wave motion to be driven by blueprint instead, or just restarting the idle animation when I start blending it back in (or probably a dozen better ways to do it that I don’t know about :P).
Also, the “pause” functionality in the Attract Points is not a great way to do things.
Timing the pause and playing animations was a lot of trial and error, I should have sent events out from the animations instead that trigger the pause.
Custom animations in Modo
There’s three custom animations that I made in Modo:
- Searching left and right animation half way down the tunnel
- The final “do I see something? I think I see something… SQUIRREL!!”
Everything in the mesh is hard rigged (no deformation), so just parenting all the pieces together, and importing into Unreal generates a skeleton for me.
In Modo, I didn’t do anything particularly exciting this time around, i.e no interesting rig, I just keyframed the bones.
Modo has export presets for UE4 and Unity now, which is pretty ace!
You can also set up your own presets:
It was pretty fun doing some animation again, it’s something I really don’t do very often, and Modo makes it pretty easy to dive in.
Ok, back in UE4, time to have a quick look over the tick event in the Scanner blueprint.
Unlike my normal lazy self, this time I stitched a bunch of things together, so you can see it in full!
I wanted quite a few of the animations to be driven by the velocity of the scanner.
I’m calculating the velocity myself anyway, based on set max speed and acceleration values, so I could have just used that value, and built some lag into it.
But I found something more fun:
I have 2 non colliding “spring arms” attached to the Scanner root node, one that is slow to catch up (used for body tilt), one that is fairly quick (used for tail rotation).
This was inspired by some amazingly cool animation work I saw Greg Puzniak doing in Unity3D. It’s not up on his site, but he has cool matcap stuff up there that you should check out! 🙂
So in a lot of my blueprint functions, I get the distance from the spring arm to the arrow, and use that to drive laggy rotation:
Despite the comment in the blueprint, when I tried to use this for banking, the ATM swallowed my card (har har har).
So most of my procedural animation is driven this way.
When I’m not playing the override animations, everything except for the up and down bobbing is procedural. Which is pretty silly, because that’s a sine wave, so it’s not really an Idle animation, and I should have got rid of it.
The rest of the blueprint is about keeping track of how far along the spline we are, how close to the next point we are (so we can start playing an animation, if necessary), and then setting the world location and rotation of the Scanner from the distance along the spline.
Next-gen volumetric fog
Is something I don’t know much about, so I just made a hacky material UV offset thingo 😛
I say “made”, but there are some great light beam and fog examples from Epic included in the engine content, so I grabbed most of this thing from those examples, and here:
I don’t think I really changed much from the content example (I honestly can’t remember), but I did add two parameters that adjust the tiling offset of the noise texture:
As the Scanner moves along the path, it increases the FogForwardOffset which pans the U coordinate of the UVs, so that it looks like the cone is moving through a volume. There’s also always a little bit of panning going on anyway, even when the Scanner is stopped.
As the Scanner rotates, I scroll the V coordinate, just so the noise in the beam doesn’t stay fixed. The rotation isn’t very convincing, so I could probably do a better job of that.
There’s not much going on in the blueprint, but I put whatever I could in there rather than in the material:
The idea of the scene was to be almost entirely lit by the scanner, but I do have a bunch of static lights scatter around too, just to give some ambient light.
There are also two stationary lights in the scene to get highlights where I want them (the lights selected in the screenshot above).
One of them is a spotlight, used to hit the puddle and left wall.
There is also a small light at the front of the tunnel that has “Indirect Lighting Intensity” set to 0, so it doesn’t affect the bounced lighting.
This is the light that hits the scanner here:
This light is quite bright, so when the Scanner hits it, the rest of the environment darkens down, which (hopefully) puts the focus all on the Scanner (yay for auto-exposure!).
There are only two shadow casting lights in the scene, and they are both on the Scanner.
One of them is on a giant point light, and is super expensive, which is the main reason I limited shadow casters everywhere else:
There are also two non shadow casting spotlights on the side of the scanner that rotate and project patterns on the wall.
For some reason that I can’t remember, I decide to generate the pattern in a material, rather than do the smart thing and use a texture.
I’m modifying the “VectorToRadialValue” function to generate bands, then fading it out in the middle bit.
Seriously though, unless you have a really good reason, you should probably do this in a texture 🙂
So I *think* that’s it!
I’m sure there are things I’ve missed, or glossed over a bit, so feel free to ask questions in the comments and I’ll fill in the gaps.