While cutting edge animation problems are exciting there is a problem that come up in games quite often where a character needs to be able to go up to and use some type of object. Pull a lever, push a button, grab a mounted machine gun to mow down the bad guys or just move an AI enemy to fixed positions in the gameplay space.
Animation Alignment solves the problem of connecting an animation with another character or object. There are some common approaches for this and the approach that has been quite successful for many developers is to include in the animation a joint that functions as an alignment reference from the root of the character.
That way the game code can get the alignment reference joint and move that joint towards the point on the character/object that it references. It also gives the animator a reference point to work with.
In some of my alignment code I made the procedural alignment hidden as part of the animated movement automatically so that you wouldn’t notice that an animation was being warped however adding the ability for the animator to control the alignment weight can give better results.
Alignment can be enough for pulling levers, pushing buttons and mantling obstacles. There are some complexities when you are aligning towards characters as you’ll want to align both characters depending on what the actions are that they perform.
I like to avoid issues in situations when you are aligning and I will keep the alignment active during an action, not just during the alignment part. This is to avoid slight precision issues coming in. You don’t need to do this if you attach to the object or if you can fix all the causes of the precision issues.
In earlier days I made it so that the name of an animation served as a marker that the other object would be animated. The logic was simple, if you play an animation and there is something attached or connected to the character the code tries to play an animation by the same name on that object. If it doesn’t find one that’s fine. Easy to understand and implement.
In a recent game we decided to up our game and allow our timeline editor to play animations on multiple characters and objects at the same time, each play animation event simply had a target that they played on and in the preview we could see all these characters and objects animate as a complete sequence.
With machine guns and other emplaced weapons it’s quite common that these are placed at positions or on top of vehicles and that they generally have a fixed position relative to their base.
The technique that I found useful here is to first use alignment to move the character into a good position and then the character is attached to the emplaced weapon.
Attaching the character is a good way to keep the precision issues down and choosing to use the emplaced weapon as parent means that you can support the base of where the weapon is attached moving (like a car, spaceship or pirate ship) and also you are animating around a fixed pivot point.
Generally for emplaced weapons the characters need to move and aim them and the obvious solution there is to use a blend space. A blend space does not give you the best fidelity as generally the workflow for blend spaces means you will only want to supply a few animation poses.
There is another approach that can improve that fidelity and it is through the use of seeking in animations. So instead of just using a few poses what you can do is to create an animation for aiming from the left to the center and then to the right. This way you have coverage of poses for every degree and if you add two more animations for aiming up from left to right and aiming down from left to right you will have the same coverage as a blend space but at higher fidelity.
Additionally on top of those blended animations what I’ve used are additive animations that bring in some noise on top of the poses to give some life to the character aiming the weapon. Same with the firing animations and reloads, you want to do the actions relative to the aimed pose so you will either do these animations additively or through a layered blend.
If the state that decides the blend values/etc. for the weapon can easily be copied entirely from the character that is using it you can avoid the problem of synching later. If optimizations are required you could reduce the state that is shared to a subset but you want to avoid optimizing this part too early as you don’t know exactly what you’ll need to feed to the animation (if suddenly velocity is required).
Depending on the object IK can sometimes be skipped as alignment can handle most of the synching between object and character.
However in situations like the machine gun using IK for the hands will ensure that the hands are correctly holding the handles.
If the object also has foot holds you’ll want to use IK there too. The annotation of objects with IK targets is usually done through setting up plugs/sockets/bone annotations that can have offsets relative to a bone in the objects rig. Annotating it once in the object asset is a generic way of solving this so that you don’t have to manually annotate each animation with what the IK should be attaching to. Generally just being able to control the blend weight of the iK is enough to handle the transition into and out of holding those handles.
While this is a known and stable solution it has certain problems and I can see a lot of them being improved via motion matching and custom event tagging.
Pulling a lever can be captured for in motion, standing still, etc and the gameplay code sends information to the motion matching that it wants to reach a specific event at a specific location.
Improving on animating the emplaced weapon could probably also be done via motion matching as you can generate a path around the pivot point to find poses. The exciting thing about new tech is finding ways to use it.