Quadruped Foot Placement Tutorial
0 - Introduction:
This tutorial will cover the set up needed to produce realistic foot placement behaviour for quadruped characters regardless of terrain.
A video showcasing this behaviour can be found here: https://youtu.be/-HuxE63C38Q
What you will need:
This tutorial assumes you have access to some character assets. For the most basic implementation of foot placement behaviour, you will need at-least a skeletal mesh. We also assume that you are able to produce the Unreal specific character set up (movement handling/game logic) to suit your needs.
We will be using assets accessible from the Unreal Marketplace (Animals: Deer pack released by GiM). While the skeleton of your character might not match the one we will use for this tutorial, we will cover the way we tune our IKinema Rig to help you achieve perfect foot placement behaviour. As such, this tutorial is intended to be independent of specific assets used.
As with a majority of these tutorials, the basic formula for setting up the complete IKinema behaviour follows the same overarching work flow as follows.
1 - Setting Up The IKinema Rig:
1.1 Creating the rig.
1.2 Assigning Constraints.
1.3 Tuning Constraint Parameters.
1.4 Tuning Bone Parameters.
1.4.1 Tuning The Spine.
1.4.2 Tuning The Front Legs.
1.4.3 Tuning The Back Legs.
1.5 Testing The Rig Tuning.
2 - Setting Up The Foot Placement Node In The Animation Blueprint: This is where we will set up the IKinema Foot Placement Node. This node will then modify your input animation to ensure that the feet of your quadruped character are reliably placed on any terrain it may be standing on.
1 – Setting Up The IKinema Rig:
(Note: The rig settings used here may be subject to change depending on the quadruped skeleton of your character.)
The IKinema Rig is where we define which bones we want to give position/orientation tasks and where we tune various parameters that control the behavior of IKinema's full body IK solver.
1.1 Creating the IKinema Rig:
In the content browser, right click -> Hover over the "Animation" option in the "Create Advanced Asset" list and select "IKinema Rig" shown below.
A prompt will appear on your screen asking for a skeleton to use when creating the IKinema Rig.
Navigate to the skeleton that corresponds to your character and click OK.
Open the newly created IKinema Rig and delete any non-essential bones.
1.2 Assigning Constraints:
Note: Since you may not be using the same skeletal-mesh we use in this tutorial, ensure that the bones and tasks you assign them correspond to those shown in the screenshot shown below.
We will be creating 10 tasks in total. 4 for the feet, 4 for the knees, 1 for the hips and 1 for the chest.
The specific bones and the constraints we will assign them are shown in the screen shot below.
Right click on the bones shown one at a time to bring up the "Create Task" menu as below (shown for hips bone and Hip task).
Hover over "Constraint Type" and select the relevant constraint for the bone you have selected to add it.
Repeat this process until you have given all 10 relevant bones the correct constraints as illustrated in the screenshot at the start of this section.
1.3 Tuning constraints:
The constraints we assign will have pre-set values by default.
The only constraints that need to be tuned are those of the front feet.
With the IKinema Rig still open, select "Constraints" in the "Hierarchy" panel. Select the constraints that you assigned to the front feet bones of your character.
For both set their position and rotation weights as below.
Position Weight: X:100, Y:100, Z:100
Rotation Weight: X:30, Y:30, Z:30
Note: We increase the position weight as we want these bones to have a higher priority in reaching their target positions when the solver is generating full body poses.
1.4 Bone Tuning:
By default, the bone weights/retargeting gain/retargeting DoF Gain will all be set to 1 for all bones in the rig.
We will be modifying these pre-set values for the chains of bones that make up the:
- Front Legs
- Back Legs
1.4.1 Tuning the spine:
Holding Ctrl, select the bones which make up the spine of your character.
Reduce their "Weight" in the "Details" -> "IKDefinition" panel to 0.4 as below.
Note: Reducing the weight of a bone stiffens up the joint between said bone and its child. This helps to preserve their orientation which prevents unnatural bending.
1.4.2 Front Legs:
IKDefinition - Degrees of Freedom:
For a quadruped character, we only want the legs to be able to rotate around a single specific axis.
Identify which axis in the bones local space is the rotation axis.
Note: The axis shown on the bone in the rig is that of its local space.
In the IKDefinition tab in the Details panel, Leave only this axis selected shown below.
NOTE: The first bone in both front leg hierarchies should be set to move in all three degrees of freedom if your skeleton structure is similar to that of the deer asset used here.
We will be reducing the retargeting gain for the front legs of our character which will allow the solver to position and orient these bones with more freedom.
Select the first two bones in each of the front leg hierarchies.
Enter a value of 0.35 for the "Retargeting Gain" in the Details tab with the bones selected as below.
Retargeting DoF Gain:
Note: The "Retargeting DoF Gain" is a multiplier to the "Retargeting Gain" along a specific axis. We will be reducing the retargeting gain along the axis of rotation for our characters knees and legs to allow them to bend more freely.
Select the knee bones of the character and change the "Retargeting DoF Gain" in their local rotation axis (this is the Z-Axis in our example) to be 0.001 shown below.
The "Retargeting DoF Gain" for the other axis will remain at their default value of 1.
For the bones above and below the knee in the hierarchy, select a retargeting DoF gain of 0.1 in the Z-Axis shown below.
Note: If the rotation axis you want the leg joints to bend around is different from the example here, set the re-targeting gains in that axis as we have done for the Z-Axis.
1.4.3 Back Legs:
IKDefinition - Degrees of Freedom:
We will be limiting the Degreed of Freedom in the same way we did for the front legs.
Select the bones which correspond to the back legs of your quadruped.
Ensure only the degree of freedom corresponding to the rotation axis in local space of the leg bones is ticked as below.
Note: This axis may be different for your asset.
The Retargeting Gain of the back legs will can be left at the default values.
Retargeting DoF Gain:
Select the bones corresponding to those in the image below, the bones above and below the knee in the hierarchies.
Set the "Retargeting DoF Gain" to 0.001 for each as shown below.
Select the bones we have given knee constraints.
Set their "Retargeting DoF Gain" to 0.1 in their local rotation axis.
1.5 Testing The Rig Tuning:
With the IKinema Rig for our character tuned and the Rig still open, click on the "Simulate" button in the top toolbar. This will allow you to move the constraints and see how the body reacts.
2 – Animation Blueprint:
With the IKinema Rig created and tuned, we can now set up our animation blueprint for our character. In here we will be selecting which constraints (that we set up in the IKinema Rig) we want to ray trace to the ground below them and be placed based on their orientation from the ground.
Create an animation blue print corresponding to your characters skeleton.
In the Animgraph, right click and search for "IKinema Foot Placement".
In the action list, select "IKinema Foot Placement Behaviour using rig *your rig*" to place the node.
Pass your desired input animation to the "In Pose" pin on the recently placed Foot Placement Node.
With the foot placement node selected, navigate through the advanced options to the "End Effector" section.
Here Click on the "+" symbol shown below and add 6 elements.
The 6 elements will correspond to the bones of the feet, hips and head task we assigned in the IKinema Rig.
Note: We will not be adding the knee tasks as elements.
Right click on the foot placement node in your anim graph and select refresh.
This will bring up a number of new pins on the node.
Set the Alpha value for each of the limb transform elements that now show to 1.
Connect the output of the Foot Placement Node to the "Final Animation Pose" node.
With the IKinema Rig set up and tuned to produce realistic behaviour and an Animation blueprint containing an IKinema Foot Placement node set specifically for our character you are free to place your character into the game world.