This development blog post is for the project “And I Must Scream” at Stitched Mouth Studio. Any suggestions or comments are welcome!’

In the last post, I showed how to calculate character feet offsets and hip offset and adjust the capsule half height. I am going to show how I used those values to actually update the bone positions in animation blueprint.

Variables in blueprint that starts with a capital “M” means member variables exposed from C++.

First, at the end of the animation blueprint event graph, I update the variables needed for using two bone IK. I use the m_animIKRightEffector / IKMeshZScale to make the effector vector for right foot since our model mesh was scaled. The CheckValidMeshZScale node is basically a function making sure that z scale is not equal to 0, or we’ll get division by zero error.

NOTES: In the second screenshot, I use the effector values as the “Z” elements in the vectors. This may change according to different skeleton setup, it requires double checking the joints’ local orientations so we don’t get weird poses from the skeleton.

IKAnimBP_EventGraphLastPartSetIKParams.PNG

IKAnimBP_SetIKParams

Inside the animation graph, I cached the locomotion state machine first, and then convert from local to component space. After that, we can use Two Bone IK node on the bones that we need, and cache the final pose after converting it back into local space.

IKAnimBP_AnimGCachePose.PNG

IKAnimBP_AnimGIKPart.PNG
One notice, the settings inside Two Bone IK nodes are “CRUCIAL” and can be easily overseen! Especially between choosing World Space, Component Space, Bone Space, and Parent Bone Space. Right here, we use bone space for the effector location and parent bone space for the joint target location.

IKAnimBP_AnimGTwoBoneIKNode.PNG

After all the above, we can blend between the two poses that we cached according to the character’s current speed to get our final animation pose.

IKAnimBP_AnimGFinalBlend.PNG

At this point, we are basically done. Another thing that we added is to make sure that when the animation enters our Idle/Walk state, we enable our FootIK check to make sure it will update. This is achieved by adding an Entered State Event notification.

IKAnimBP_EventGraphEnableIKWhenEnterIdleWalk.PNG

So far, we’ve only implemented translation IK on the character’s feet. We might also add rotation in the future if needed.

Reference:

[1] Unreal documentation: IK setups

[2] Applying IK Constraints in UE4

[3] IK Foot Placement System (most of our implementations followed this awesome post!)