How to control player's arm with the mouse?

I am new to Unreal Engine 5. I am making a first-person game. I want to control the player’s arm (not as one piece) with the mouse when clicking and holding. Please tell me how to make it.

1 Like

You can do this in the animationblueprint by using the IK system. Basically you have the bone position / rotation of the arm which you can offset using IK to a vector of how much the mouse moved up / down while you hold the mouse button. This can get you started:

3 Likes

Thank you, can I add physics?

1 Like

Yes you can. It can all be processed as additional vector information on top of any animation or pose currently playing. You are looking for “physical animation” or “procedural animation”, techniques often used to calculate realistic movement and also hit responses in boxing games.

2 Likes

Thank you, I used IK on hand bone, and I am going to use physics, I still do not know the nodes for adding hand value to mouse values, I found this picture
image
could you please help me.

1 Like

Shown on that image you store the mouse input into 2 variables on the character. the AnimInstance (blueprint animation) used on your character can pull those variables and use them to blend your IK setup. You can do so using for example this node (Two Bone IK):

2 Likes

Thank you, you helped me a lot, I really appreciate it, but please help me finish this, I started a third-person project and put the camera in the first-person view, the image is from the internet, I made the same


this is the IK setup

these are the only things I made, could you please tell me what to do step by step? I am completely new, thank you agin :slightly_smiling_face:

What you need to know on the first image:

Axis events execute every frame, so on 60FPS your axis value variable is going to be set to something 60 times a second which is not very useful because we slowly want to interpolate from a position A to a position B, so we are going to take a different approach:

The image you showed me earlier did it correctly:

Every frame, it adds or subtracts the mouse input to the final axis value, while limiting that value to -65 and 65 (which I assume are going to be an offset in centimeters for the arm).

To get a framerate independent movement value you should also multiply your AxisValue (from the event pin) by World Delta Seconds. If you do that, the arm movements will be the same speed on 30FPS as they will be on 120FPS.

When you do not move the mouse the axis value is 0 and it can be anywhere between -1 and 1. multiplying it by 0 like you do is not going to produce a useful value since your mouse direction is always going to be 0.

At 4:00 of the IK video you can see how the Effector Location on the Two Bone IK node is altered to move the bone around. This location is basically the offset you stored earlier on the character as the Axis Value variables, because they will move the bone up/down/left/right relative to the original bone position. So you need to read theese values in your animation blueprint, from the character.
If you follow this video from 14:00 you will get an example on how to work with variables and pull them from the character: