What can I do to make the hand hold the grip of the gun even while the character is bending downward or upward?

I have a problem implementing the Hand L Goal (related to IK Rig) to attach the grip of the gun so that wherever the gun moves, the hand will follow it. What I tried was setting the Hand L Goal Position to the position of the socket that I had added to the grip, and the Hand L Goal never correctly matches the position of the socket, so I manually moved the socket somewhere far from the grip, but it put the Hand L Goal in the correct position. The problem is that when the character bends downward or upward (using an aim offset), the Hand L Goal is no longer in the correct position that it was before.

Here the character is holding the grip correctly:

When it aims downward or upward, the hand is no longer holding the grip in the correct place:

image

Blueprint:

I tried different transform spaces, but it didn’t give any good results.

What can I do to make the hand hold the grip of the gun even while the character is bending downward or upward?

You will need to show the skeleton hierarchy and the node linkages for forward/up/down (from the animation preview view) to be able to debug this.
Chances are, the parenting of the objects is going wrong somewhere, either in linkage, or in how the data is interpreted.

I don’t see a problem in the hierarchy.
This is the animation blueprint where I have set up these:

I thought this was happening due to me not setting the position of the Hand L Goal Position correctly based on the target socket in the character blueprint, but I tried setting that position directly in the IK Rig and the same problem happened.

If the AimOffset poses you’re using have the ik joints ( ik_hand_l/r ) that are following the hand_l/r, you can simply use a two bone ik node after the AimOffset node, where you set the hand_l/r position using the bone space from ik_hand_l/r.
By doing that you’re fixing the AimOffset lack of precision by forcing the hands towards where they should be.

The two-bone IK was so useful that I didn’t know about it. I created my aim offset even before creating any IK for the character; that must have been causing these problems for me because in the aim offset poses skeleton hierarchy, I don’t see anything to move the bones using the IK that I had created. The aim offset is just using the spine bone for bending down or up; it does not use any IK, and it seems IK is not functional in the poses. In the poses, can there be keyframes for the IK, and is it possible to move bones with the IK goals in the poses?

You can use virtual bones within the skeletal hierarchy so that they will follow what the hands are doing.
The AimOffset doesn’t natively use IK to move stuff around, what it does is to average the poses by blending them, that’s why the hands position is not always reliable.

I suggest you to use virtual bones, create one for each hand ( call them ik_hand_l/r ), then after the AimOffset use the TwoBoneIK node for each hand, and set the hand_l/r transform to be bone space and use the ik_hand_lr/r joints, that will solve your issue with the hands alignment.

Overall hand IK is a suggested destination.
There is no guarantee what so ever that a given skeleton is able to reach the goal accurately all the time.

You probably want to make a better aim offset animation for grip like weapons so as to mitigate the issue a bit.

But the most important part is likely going to be (like IRL) to tailor or fit the stock of the weapon so that the grip can easily be reached by the skeleton/structure of the specific character.

If you are looking to make characters modular, you probably need to shrink down the weapon size to some arbitrary number or make the grip be a lot less forward than you’d need for larger (longer arms wide shoulder) characters.

Also fwiw an aim offset tracks all bones in an animation and interpolates mathematically the position of the different poses you set. Not “just the spine”.

Last but not least.

With first person you need to look down sight and make AO poses that are precise before you can run any IK.
With third person no one cares. Simply adjust the weapon to be in the hands at all times (socket it to the forward grip hand not the stock). And you are probably fine to always have the back hand (right for normal people) use IK to adjust in all skeleton sizes.

In the documentation of Unreal Engine for virtual bones they don’t specifically use an aim offset, and they add a Layered Blend per Bone and Apply Additive together. In my setup, I have a problem understanding whether I need to create another Layered Blend per Bone and an Apply Additive node, and even if I create those new nodes, how should I connect the new nodes to my first setup?

Here the Layered Blend per Bone that is connected to the aim offset is using the branch filter for blend mode, but the Layered Blend per Bone under it uses the blend mask for blend mode, so firstly, I don’t know if I need the new Layered Blend per Bone, and I also don’t know where to put it:

Are you sure Two Bone IK should be after the aim offset and not before it?

I tried the below, and it seems to be fixing it:

First consider that the virtual bones page shows you an example of how to use them, so you don’t necessarely need to replicate the same setup.

Reading again your first post I have to add that I used IK Rigs only for retargeting, never for gameplay purpose, so it might be that is causing some issues there.

Going back to your reply:
Do you need to have additives? or you’re ok with just having montages from slots?

I suggest you to test one thing at the time, namely Locomotion+AimOffset only, and see if the hands issue is still there, then try to add the TwoboneIK node to eventually fix the hands alignment issue.
If you notice that even with AimOffset + TwoBoneIK the left hand doesn’t really work as expected and the left arm is over-extended, you may want to update the poses so that the rifle is closer to the body, which will fix the over-extended left arm.

Don’t just add nodes, try one step at the time and see which solution works for you, there are plenty of tutorials/courses around regarding shooters.

Yea no.
Moving the rifle is not the right way, but it’s the correct “idea”.
Rather than attempt something you cannot achieve, just attach the rifle to the arm that’s FURTHER away.
Then you can simply adjust the trigger hand instead, which is going to almost always be reachable, regardless of the character’s size/morphology…

You may find some useful ideas or info in this post:

One of the things I find time-consuming is: let’s say I add a weapon to my character in the character blueprint and I adjust its rotation and position, and then I go to the animation blueprint to do some adjustments with the IK, but the weapon is not there! I have to go to my skeleton tree and add a weapon there and adjust it so that it will be visible in the animation blueprint; also, that weapon that I added as a preview to my skeleton tree is not going to be visible in the character blueprint, and I have to use sockets for it. Since you have worked with different weapons, is this the normal workflow that you add all your different weapons to your character’s skeleton tree as preview assets, then you adjust the poses in the animation blueprint for different grips, and then you need to add the weapons to the character blueprint again via sockets and adjust their positions and rotations again? There is no guarantee that these positions are going to match with the poses you create in the animation blueprint.

If you make an official tutorial within Epic learning hub it would be easier to find and share, since the infos there ( and maybe adding a more in depth showcase of the ABP setup ) are very useful.

One day perhaps, but I’d have to sit down and update it to Unreal Engine 5 and probably convert it to use a Control Rig instead.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.