How to obtain bone locations from an animation node in anim graphs (for IK foot placement purpose)

Hi All,

Firstly I asked this question in answer hub but I caught no answer! So I just reposted it here :slight_smile:

I want to get a bone location from an animation node in an anim graph for IK foot placement purpose. IK is usually used as a post process on animations. That means that the FK animation is going to be calculated completely and the IK is going to modify it to create more accurate animations or simply you can say that IK is used to fix joints errors. So here, for a foot placement system, I need the FK animation first and from the updated foot position of the FK animation, I’m going to cast a ray to obtain desired foot location on ground. Please have a look at this picture:


The FK animation is calculated in “default state machine”. Then I implemented a custom animation node. I want the animation node to get the updated foot bone location from its input pose and use it to cast rays and find the desired foot location on ground. Then the foot location on ground has to be passed to the “Two Bones IK” node.

The custom animation node has three overridden functions, Evaluate, Update and initialize. I think I have to do the job in the evaluate function but I didn’t find how to do it. And unfortunately the documentation are bare on the animation node sections. Almost no description about their methods and classes. So any help would be appreciated :slight_smile:

Thanks in advance for your help.

P.S: There is a tutorial on Epic documentation which is offering a foot placement system. The system is not working correctly because it uses non-updated foot positions to cast rays. That means it uses the previous frame position of the feet to cast rays and find the desired foot location on ground. Although it works fine with stationary animations like standing idles but it would not work fine with the animations which have noticeable displacements between two consecutive frames like run and sprints. In a sprint animation the feet translates significantly between two consecutive frames and using the feet’s previous frame location to cast rays can cause unacceptable results

No problem, I found it myself. Here is the how you can get the positions out from a pose in AnimGraph. First you need to create a custom animation graph node like what I did in the picture. To create custom animation nodes check this page. The anim node (FAnimNode_Base) has an Evaluate function which is responsible for working with input pose(s) of animations. The signature is like this:

virtual void Evaluate(FPoseContext& Output);

Using the Output parameter you can get the local transform of each bone:

virtual void Evaluate(FPoseContext& Output)
if (Output.AnimInstance)
FCompactPoseBoneIndex lInd = FCompactPoseBoneIndex(1); //specifies the index of the bone you need to get
FVector lBoneLocalPos = Output.Pose[lInd].GetLocation(); // gets the location of the bone. Output.Pose[lInd] returns a FTransform

Local transform here means the transformation of the bone with respect to its parent bone which means the parent bone transform is the reference coordinate system. So if you want the bone in component space, you have to consider local poses of its ancestors and add (translation) or multiply them (rotation and scale) to achieve the final pose.


hmm, i need something similar to this. However i don’t know one bit c++, so trying to implement a custom node is out of my reach. I think it’s a node that we should get built into the engine. I mean, it is quite often when you work with IK, that you want the location of the FK animation. Hope it gets added to engine eventually.

Just for everybody information, I ended up here while looking for a way to make an anim state node return a bone transform (at that specific point of the state machine execution), like “GetBoneTransform”, to then maybe use it as an IK target of another bone.
Unfortunately that is not possible due to the way/order the anim instance updates anim nodes, and the only way to get that bone transform would be to make a new anim node which got the bone transform of the other bone and applied it in the way I wanted.

For example, if I wanted to move the right hand to a random IK location, then I wanted to move the left hand to a relative position from the right hand, wherever it ended up being, this is impossible to do without virtual bones. The only solution (ASAIK) is to make a new node, for example, “IK to bone with offset” where you’d say that the left hand should follow the right hand with a local space offset applied to it.

1 Like