Basically my intention to use Advanced Locomotion V3 was to get the IK out of it, even though the Unreal Documentation provides a basic setup. But because AL basically also provides a convenient approach for embedding and handling custom movement modes. The setup also makes use of the Post Process Anim Instance node for character meshes. However in my opinion AL is to nested, and overly specific when relying on the Epic Skeleton with it’s IK bones. That is not a bad thing when you start a fresh project but can become a tedious learning curve when you try to adjust settings to existing blueprint code.
The Final Result
Generally what we want is a single character mesh for all game characters. Hence, using a single Post Process Anim Instance helps to fast prototype new characters.
As AL users know there is a video tutorial on how to adjust characters without IK bones, so in theory this should be a straight forward task when working with Character Creator 3 skeletons, which however yet have to include IK bones. But, we can actually import these characters into our “main” Epic skeleton upon import, it just shows the IK bones all grayed out for those Character Creator 3 characters.
Adding Advanced Locomotion IK Foot functionality
The first thing you want to do is creating two new enums, one for Stance (Crouching and Standing), and the other one for MovementModes (Grounded, Falling, Swimming, Ragdoll).
Next we add these to our “main” AI Master Blueprint, and Player Character Blueprint, create a new enum variable for Stance and MovementMode. Now we can update the default MovementMode from our CharacterComponent and parse this value into our custom MovementMode, we do this on EventTick.
Your project should use a Interface Blueprint, for convenient communication between your Anim – and Character Instances.
For convenience we added a pure function to get the current Post Process Anim Instance.
If you do not yet have a Blueprint Interface create one add it under Class Settings – Interfaces, then add the following function to that Interface.
You have to do above steps for your main Character and AI blueprint, except for the Interface, which we can share among our two master character blueprints.
The Post Process Anim Instance and making it work with Character Creator 3 Skeleton (No IK bones)
Create a new Anim Blueprint based on your “single, main” Skeleton and basically copy the contents from Advanced Locomotion V3, Mannequin_IK_AnimBP into it.
Since we have now the new Interface function for communicating the movement states to our Post Process Instance, we add the Interface Event to it.
Because we use two different character blueprints the Event Graph otherwise looks like this.
Create the following virtual bones inside your Skeleton:
- For “thigh_r” (thigh_r_calf_r)
- For “thigh_l” (thigh_l_calf_l)
- For the “root” bone, call it ik_root.
- For “foot_l”, call it ik_root_foot_l
- For “foot_r”, call it ik_root_foot_r
Oni: When playing back an animation on a character, Unreal Engine can either use or ignore the translation data included in the animation.
To use the translation data means to place the joints according to the animation, i.e., in our case, based on the proportions on the male skeleton – this setting of “Translation Retargeting” is called “Animation” and is the most rigid of the available settings.
To ignore the translation data of the animation means to place the joints according to the mesh itself, or rather to its own internal skeleton – that is, the bone structure you see in the Mesh editor (if you enable the display of bones), and not to be confused with the Skeleton Asset (in our case, the male Mannequin’s skeleton). By setting “Translation Retargeting” to the not-so-intuitive “Skeleton” value, the engine is told to take only rotation data from the animation and, as for relative translations, the engine will look them up in the internal skeleton of the mesh (and not in the Skeleton asset).
Thus, to make a female character look OK in ALS3 (or any other character with custom proportions), you will need to modify the “Translation Retargeting” value and set it to “Skeleton” for all non-IK bones.
We will actually use the Character Creator 3 Foot Bones for IK (otherwise it won’t work), hence click on the Skeleton Options Panel, enable Show Retargeting Options for your Skeleton, then set foot_r and foot_l to Animation!
We are now done editing the skeleton, and can continue with changing the default Advanced Locomotion blueprint code.
Editing Advanced Locomotion IK values for Character Creator 3 Skeleton
Notice some or all steps of this chapter, may be different, depending on your Skeleton setup. Here we use a Character Creator 3 Skeleton, imported with the Reallusion Unreal Plugin to our Epic Skeleton.
Basically if your Skeleton without IK Bones is not retargeting the feets to the floor beneath, do the first check, add a PrintString node into the FootIK function, which is part of the AL Post Process Instance.
If there is no ouput it probably means that the Character Creator 3 foot bones are differently setup. However we can fix this! Just edit the ClampOffsets function as follows.
Next we adjust our AnimGraph!
Oni: If you want to replace or complement ALS’s locomotion animations with your own, and do not want to follow the convention of animated IK bones (ALS expects locomotion animations to have motion tracks for the IK bones that exactly replicate the motion of the actual foot_l and foot_r), you need to modify the animation blueprint (either Mannequin_PostProcess_AnimBP for ALS2, or Mannequin_IK_AnimBP for ALS3), as described HERE.
After applying above hack and connecting the two extra AnimGraph nodes, it should look like this:
The following changes were made to the AnimGraph Nodes:
The Copy Bone Nodes Settings
- Source Bone = foot_l
- Target Bone = VB ik_root_foot_l
- Source Bone = foot_r
- Target Bone = VB ik_root_foot_r
The Transform (Modify) Bone Nodes
Node 1 Bone VB ik_root_foot_l
- Bone to Modify = VB ik_root_foot_l
Node 2 Bone VB ik_root_foot_r
- Bone to Modify = VB ik_root_foot_r
The two Transform (Modify) Bone nodes which per default have only a Translation Y value assigned to the virtual bones, VB thigh_l_calf_l and VB thigh_r_calf_r bone. These settings may be tweaked to account for your custom mesh, which means they may or may not be required. Basically it narrows legs, heightens walk angle of the calf bones etc. So you might skip this step.
Node 3 Bone node VB thigh_l_calf_l
- Translation Z = 3
Node 4 Bone node VB thigh_l_calf_l
- Translation Z = -3
The Two Bone IK Nodes
Node 1 Bone foot_l
- Effector Location Space = VB ik_root_foot_l
- Joint target Location Space = VB thigh_l_calf_l
Node 1 Bone foot_l
- Effector Location Space = VB ik_root_foot_r
- Joint target Location Space = VB thigh_l_calf_r
In my example I set a Pelvis Offset of 1, which seems to have taken care of slightly out-of-place animations.
The last step is to add the Post Process Instance to each of our Character meshes, that’s it!
The main differences to the AL default version is that we use a pure default foot bone Z value, and only marginal clamp (switch pitch) of the traced results.
Because we do not have IK bones in our Character Creator 3 skeleton we created those based on our root bone, from that added two virtual foot bones as replacement.
The Skeleton Translation Retargeting, for the most part you only need the root, pelvis, foot_l, and foot_r set to Animation.
When working on this I noticed that the AnimGraph nodes no longer showed the connected animation, which can be fixed when restarting the Unreal Editor.