IK effector bone space as a pin/var?

Is it possible to modify the effector space of an IK constraint in an AnimGraph at runtime?

Because IK constraints can have ugly “frame lag” when the target isn’t set in the space of a parent bone, it’s important sometimes to set that up. But often different animations require different IK constraints.

For example, in some animations, I might need the player’s right hand to have an IK target of his hip (for drawing a weapon). In others, I might need it to be his left hand (to hold a weapon anchored in the left hand). In still others, I might need the left hand to be anchored to a weapon held in the right hand. Every one of these potential uses requires a different set of IK constraints and a different set of weight values, at least in my current setup. What I’m wondering is if it’s possible to expose the “parent bone” of an IK constraint as a pin; that way, I can use a notify or some other variable adjustment method to say not only “this is the transform the left hand needs to reach”, but also “this is the bone that target is relative to”. Otherwise, I need a separate set of constraints for every single possible use case… or at least, for every possible use case where one-frame lag is unacceptable (which admittedly doesn’t cover EVERY use case, but it covers quite a few).

I think you complely missed the point on how IK is supposed to work.

You set a world location, the IK chain adjusts to point to that location.

Obviously you can change that location at runtime, or you would never be able to achieve anything similar.

Start by having a look at the content examples.
particularly since you are asking about weapons.

if you actually try what you’re describing, you’ll see that it doesn’t work like you think it does. World-space IK effector positions are fine when you are solving to an object in the world, because its position exists independently of the pose of the solver. It doesn’t work for solving to an effector which is itself driven by the pose of the skeleton you’re running the IK on, because poses are resolved in a single pass.

Say you want to use IK to keep a skeleton’s left hand touching a weapon mesh which is attached to a socket on its right hand. With the naive world-space approach, you sample the position of a socket on the weapon mesh, feed it to the AnimBP, and when the AnimBP calculates the pose that frame, it updates the position of the left hand to reach this target position… and then updates the position of the right hand, moving the mesh and the target socket. Now, next frame, it samples this new position for the socket, feeds it back in, and the left hand resolves to it again, at the same time as the right hand’s position once again updates.

You can see the issue here: when you sample a socket in world space you are always going to see that socket’s position last frame, not in the current frame. This creates a one-frame lag where the left hand “chases” the right hand through any animation data, because the left hand and right hand are resolved at the same time. If you instead use component space, you avoid some of the chasing (since you are sidestepping any world-space changes to the actor as it moves) but animated motion still produces problems.

The way to resolve this is to set your IK effector target up in the bone space, of the bone that ultimately drives the socket your effector is targeting. This forces the AnimBP to first resolve this bone’s position (to calculate its coordinate space) and THEN apply the IK solver to this updated position. This produces rock-solid, lock-step IK when using one bone to target another bone on the same skeleton.

This brings me back to my original issue, which is that in order to do this, you have to know the bone space you are targeting in advance. It’s fine as long as your left hand’s IK solver is always targeting a location which is relative to the right hand (you can change the position it targets, as long as it exists in that space) but it will only produce stable results IF the right hand is what moves it. So, say, you need the left hand to target a position relative to the right hand to hold a weapon, but then for a reload animation, you instead need the left hand to target a hip bone, to reach for a magazine. There’s no way, at least that I’ve found, to supply a bone name as a pin to change the space… so you need two IK solvers. One which takes in a right-hand-space location, and one which takes in a hip-space location, and then you adjust their weights. Otherwise, one of these will produce frame lag because there’s no guarantee the bone driving the target position will be resolved before the IK pose is resolved in the AnimBP’s pose update pass. But when you have a lot of potential IK interactions (left hand depends on right hand, left hand depends on hips, left hand depends on chest, right hand depends on left hand, right hand depends on upper back, right hand depends on hips, etc) that creates a huge mess of sequential IK solvers which are all at 0 blend weight except the relevant one.

I’m looking for a way to avoid this, specifically that doesn’t involve using naive world-space or component-space calculations which, as I explained above, produce frame lag when the solver’s position is updated after the animation.

EDIT: and before someone chimes in with it, no, changing tick groups for the mesh will not resolve this issue. If you consider it for a second you’ll see why; if you sample the position of the right hand after updating the pose, the pose won’t see the new sampled position until the next frame, but if you sample the position of the right hand before updating the pose, you’ll be updating the pose with a position sampled based on last frame’s data. The only way to produce stable results is to sample the position after resolving the pose of the driving bone but *before *resolving the pose of the IK chain, and the only way to sample data mid-stream in the pose update like that is to use a bone space IK constraint.

Tick group has absolutely noting to do with your incorrect diatribe on why it shouldn’t work. Which anyone can stop reading after the first 2 lines.

The content examples obviously show you otherwise.

that said,
obviously being able to expose the pin for the setting would be beneficial to someone for something - and I do believe it is already possible, since almost anything can be exposed.

Buddy, you can be smug if it makes you feel good about yourself, but this is a known issue with a known solution

https://forums.unrealengine.com/deve…hind-if-moving
https://forums.unrealengine.com/deve…-1-frame-later
https://forums.unrealengine.com/deve…hind-animation

https://forums.unrealengine.com/deve…hand-placement
https://answers.unrealengine.com/que…t-hand-ik.html
https://answers.unrealengine.com/que…4116/view.html
https://answers.unrealengine.com/que…sition-to.html

I could keep going but it’s getting boring. And you may notice how often “change the tick group” is (to your point, incorrectly) offered as a potential solution to this issue in these many threads and AnswerHub posts, which is why I decided to pre-empt it here.

You enjoy those toy Content Example tutorials, but when you try to actually implement pose-driven IK in a real game with real animations you will see that this is a common edge case which pops up when dealing with pose-driven socket rotation and translation.

Would you mind explaining how? If you could demonstrate how to expose this pin you might actually contribute to this thread.

Usually, every parameter on any control has an Eye option or an Expose checkbox. In the details panel. Normally to the right of the editor when selecting the node.

But again, if your solution is “change tick group” you are 100% doing things wrong.

If complex Full Body IK can work 100% glitch free with the default tick group, so can anything else.
The problem is much more likely to be that you don’t know how to use transforms to go from world to local (or whatever else) before passing the vector to the IK node / or solver. Since we do have at least 3 different solvers. Maybe more now with Control Rig.
off the top, FABRIK, CCDIK, and LegIK.

oh. And when you actually do change tick group, is normally when Physics alters the state of the animation so your solver goes fishing for wrong values. Some times.
if you track your gun with a socket location that becomes useless as the world position of the gun in world space is always accurate.

Brother, I’m fully aware changing tick group will not work. My whole point was that this is often suggested as a solution (even though it’s not a solution). I was trying to get out in front of that recommendation by saying that it won’t work (there are cases where it works, BTW, but those are cases where changing the tick group of the IK-using actor causes it to be processed after some other object in the world which it is IK-ing relative to, it’s not useful in the general case or with pose-driven animations)

The “space” settings don’t. What you’re saying is definitely true of most BP-exposed vars but AnimGraphs, like shader graphs and niagara graphs, use more restricted logic. The “space” settings on Component transform nodes cannot be exposed as pin, only effector locations. At least near as I have been able to figure out.

. I assure you, I know how to do transform conversion. If it was a transform conversion problem I’d get really clear issues like the hand stretching all the way across the map or being in the completely wrong direction. I can tell the difference between “the hand is resolving to a completely incorrect location” and “the hand is resolving to a one-frame-old target position because the update sequence is delayed until after the full pose is resolved”. You say “If complex Full Body IK can work 100% glitch free with the default tick group” but the issue is that Full Body IK only works glitch-free relative to WORLD controllers. You’re adjusting the body to suit other actors in the world (reaching for a ledge or holding on to a motorcycle or whatever nonsense example case you care to name). You’re not using the pose to drive other elements of the same pose. This, as I keep repeating over and over and over again (but you keep not reading it) involves special considerations, because you need to partially update the pose. You need to resolve the current frame transform of* one* bone and use that to drive the current frame transform of another bone within the same pose pass. Because the pose is resolved in a single pass, you cannot do this easily. The only way to do so is to use bone space transform drivers in your IK solver, precisely because using bone space transform drivers forces a pose to be partially resolved to calculate the space.

Maybe try placing your IK In a PostProcess animation blueprint.

That should ensure that the calculations of the current pose are up to date - before applying IK to it.
​physics are still happening after.
Usually you use the ppabp for aninmdynamic nodes.

Changing transform mode in an IK node does not magically pause the animation, get the accurate value, and moved the other object/bone/chain to it.

It’s just a different space value wich being LOCAL is more accurate (float precision can matter too if you use world locations).

Also, just adding to this, since I did have a look and indeed Effect Target is not something you can expose without stealing the node C++ and re-compiling it with the exposed pin.

You can always just use a blend by BoneControlSpace

you can get a switch from typing switch bone control space. and promote the selection pin to a var to get the drop down variable defined.
you can then move the pin to blend poses by Bone Control space. Right click and add pins to expose the various types.
Feed differently configured IK nodes into the different poses.
Pin the variable you created.
Set the default pose to the baseline animation.

And you worked around it in BP without having to compile a specific BP class with the exposed node.


Keep in mind that you are probably killing fast path by doing this.If the thunderbolt sign is gone from the blend you may be better off exposing the pin in C++

Maybe I misunderstood you but last time I checked you can’t run switch functions from an Anim Graph. Also, I’ve recently had this same exact issue and I’ve found that it dates back at least 7 years so it’s a ridiculous issue that should have been resolved eons ago. I think it’s quite ridiculous that something as fundamental as hand placement has no proper procedural solutions. Two-Bone IK and Sockets is the closest thing aside from the fact that the way they are designed prohibits you from ever receiving the location at the proper time and so results in the hand always lagging one step behind the socket.

I mean honestly, it’s almost embarrassing to even mention this fact to people when they ask about this issue on almost a daily basis…To have to admit to people that the only proper solution is to tailor handmade animations specifically for hand placement if you want it too actually be accurate. When we have Ai out performing Artists on a daily basis and Nvidia showcasing Physic-Based Ai-Driven Animation systems.

You can run whatever from whatever - but the anim graph should always have no code anyway so what you can run from it is kind of inconsequential.

All IK positioning is done in the character - the animation just uses whatever variables have been set for it by the character.

And its you who’s evulating the wrong frame. Either set the actor tick group correctly, or calculate the next frame, not the current frame.
Not that epic isn’t at fault mind you. But what they allow for has nothing to do with how you implement things.

The engine allows for “everything” since you can always code up c++ for it. And you sort of should for special things like IK anyway. Relying on BP means slower computation.

We’ll I get that, I mean the planet provides us the resources to build rockets and go to Mars and if you haven’t built a rocket and gone to Mars then that’s on you…

What I’m saying is, there is no need for an Elitist attitude. Just because the ability to do something is there doesn’t mean that it’s my fault I don’t have the time to expand the capabilities of the Unreal Engine by modifying it’s source code.

Using that Logic I could create my own Social Media platform, so I guess it’s also on me that I’m not a Millionaire.

The point is that where not debating if someone could build a rocket and go to the moon or mars or if it’s my fault for not doing so…I honestly don’t care if I could program the engine to make games for me if only I would take the time to study Ai Neural networks and build my own inside the core game source code or not.

But I like your, it’s not the developers of the software who are at fault, it’s you…approach.

And honestly, I don’t know where your getting this information from about running blueprint functions from an Anim Graph…I’ve never seen anyone ever do this and I’m quite positive it’s impossible without an incredibly serious overhaul of the entire animation system in the Source Code…to even suggest that people should modify the source is a complete cop-out and should get over themselves.

btw If you’re so confident this can be done then you should make an IK system that trumps the one in Unreal and put it up on the Marketplace because I just checked and there aren’t any systems like that available.

There are or were anyway tons of IK systems out there.
From power IK to Smart Motion to another thousand different full body IK solution that allow for just about anything from octopedal to Npedal beasts.

So again, I’m not really sure what you are even looking at…

And it shows again that you don’t understand much of this when you say that I somehow suggested you need to edit the engine code to do it.

No such assertion was ever made by me or anyone else as far as I’m aware of.

Heck, Laurent is likely the only one who went that far to get the gate of steps going for animation purposes - and there was really no need to do it via the engine source either which is why a plugin was created for it.

Further lack of knowledge is demonstrated by your

First of, no one said anything about functions. Let’s chalk that to Cyberdine injecting non existent sub text into the version of this topic you are reading I guess.

Secondly. Study up man.
You are trying to run before you can even crawl.

If you can’t provide an actual solution then you shouldn’t claim that one exists

In case this isn’t clear to someone else the “answer” is:
Do your own math.

All you need to do is get the position of the next frame - and let’s not call it a frame since its ambiguous and could be confused with an animation frame of which there is no such thing in unreal - Its the next Delta Time position of the bone/socket whatever (if whatever is simulated, again, do the math for it).
And you do the trace / math off of that position.
Done.

Have you figured out the solution to your problem?

Based on my understanding, you want to get the local space of a particular bone but set it in global space?

Have you tried tinkering with calling the node GetSocketLocation(FName) which returns the location of a bone in global space. You can do this in the update event of your AnimBP and pass it into the ControlRig. Then you can pass that value as the effector of your IK function in the ControlRig.

If you want more control you can also create a control/virtual bone and set the virtual bone in Global space and use the “Get Transform - Bone” node to get the bone in Local space if you want the local value of the bone.

Thats not the value of the next delta time. Thats the current value.
It wont work.

This was added to the engine a while back.
Try it.