EDIT: I have discovered that the built in crouch function changes the height of the players capsule, so the method I used of getting the capsule half height on construction of the actor will not work right when crouched, to fix this simply get the capsule half height in the IK trace function and apply it directly.
The blueprint does not have smoothing. See post below for foot angle on sloped surfaces.
The method used is a slight variation of the one included in the content examples. If you’ve tried that one, you may have noticed that it does not work on objects like stairs which are below the characters collision capsule and one or both feet remain hovering in the air and are fully stretched out. To fix this we are going to move the characters hip so that the entire character moves down relative to the capsule and the feet are able to touch solid ground.
The first step is to setup your characters skeleton properly, your legs can only be made of two bones from the ankle to the knee and from the knee to the hip; the bones in the feet and toes do not matter. Your bones must be parented in the traditional fasion, the hip bone is after root and moving the hip should move the entire skeleton: b-hip>b-right-thigh>b-shin>b-foot>b-toe.
You will need two knee target bones (these do not seem to be necessary for FABRIK nodes) and two feet target bones, these bones MUST be parented to the root bone so that they do not move when the IK system tries to reposition the feet. When you make your animations, make sure your feet target bones sync up with where your feet actually are in the key frames and your knee targets are always in front of where your knee is supposed to be pointing, the easiest way to do this is to have them copy the transforms of the controls in your actual animation rig.
See the image below.
Once the skeleton is setup properly and imported into the engine with animations you need to add sockets to the knee targets and feet targets.
Next you will create from top to bottom what is shown in the image in the attachment.
An explanation of what is happening, take note that all calculations are in WORLD SPACE:
On construction of the actor we get the characters capsule halfheight and calculate how tall 1/4 of the capsule is.
At every rendered frame we call our custom function IK foot trace in the characters event graph for the right foot and then the left foot.
The function gets the xy location of the socket for the foot target and offsets the z to 1/4 of the capsules height, it then traces straight down to a point determined by the input tracedistance which is calculated from the midpoint of the capsule.
If the trace hits something the hit location is sent out to be used for repositioning the foot, also the vertical offset between the bottom of the capsule and the hit location is calculated to determine how far the characters hip should be offset so that their feet can reach.
While doing the above, the function draws a box to show where the foot socket is and a sphere to show where the hit location is.
After the function is finished, in the event graph the hitlocation (effectorlocation) is offset by some z value so that the mesh doesn’t sink into it’s ankle where the foot bone is.
The hipoffset from each foot is then compared to see which one is the biggest, the biggest one is sent to the animation blueprint and used to lower or raise the characters hipbone in relation to the collision capsule.
In the event that the trace does not hit anything, for example when the character is on a ledge and one foot is sticking out over the ledge, the IK for that foot is deactivated by setting the alpha to 0.
In the animblueprint eventgraph, the hipoffset is smoothed using interpolation so that when running up stairs the character doesn’t rapidly shake up and down, it’s then turned into a vector for the actual bone control node.
Anim notify events placed in the walking animations activate or deactivate the IK for each foot when the characters foot makes contact with the ground or lifts off; if the IK was always active the feet would never leave the ground and it would look like the character was sliding their feet back and forth. This causes issues when the character goes from moving to standing still, the IK doesn’t turn on properly through anim notifies and the feet positioning becomes wrong, so the speed of the character is checked to see if it’s almost 0 and then the IK is activated manually for each foot.
In the animgraph we use a transform node to offset the hip bone and two IK nodes for the feet, take note that your knee target socket locations are used for the joint targets in the IK node; if you don’t want to make knee targets, you can use the FABRIK nodes instead which work just as well.
In the IK nodes, your effector bone should be the foot and space is WORLD SPACE.
In the FABRIK nodes, your tip is the foot bone and root is the thigh bone.