Help with Inverse Kinematics

TL;DR: How do get rid of the gap between the LowerArm “wrist point” and the Hand “wrist point” in the pictures below where I am using IK?

Hi!

I’m trying to make a weapon that looks nice, and I understand that inverse kinematics is good for that. I’ve read the article 2 Joint 2 Limb Inverse Kinematics, and I understand some of it, but there are parts of it that I just can’t visualize.

My problem is (I think) that the script provided at the end of the article assumes that the 3 points of the triangle formed by the shoulder, elbow, and wrist/goal all form a plane aligned to the world’s Z and Y axis or something (again, I don’t really know), but they really aren’t, and it’s causing a small gap to appear between the “wrist” vertex of the triangle and the goal position.

wrist-gap

alignment

You can also see it happen in the demo place provided in the article I linked above:

You can see here that the Hand of the character is not in the same position as the goal position (the red sphere); it is offset by 0.5 studs, the difference between the shoulder position and the wrist position:
bad-alignment

When no joints are used, you can align the vertices of the triangle however you want, this creating the desired outcome below:
good-alignment

They way I have my rig set up is like so: The gun is welded to the head of the player, and I re-weld the hands of the character to some parts on the gun that I can animate reloading, aiming, etc.
What I ideally want to happen is to use IK to position the arms so that the LowerArm “wrist point” aligns with the Hand “wrist point”, but being unfamiliar with the math to do so, it’s extremely difficult for me.

I would greatly appreciated if someone helped me get through the math to solve this. Thank you!

1 Like

Haha, I had to deal with this problem awhile ago as well. Although barbaric, what I did is depending on which hand it was (left/right), I just offset it by 0.5 studs.

3 Likes

Lol yea I would just do that, but that only works with the default R15 package (the grey character in the third image)
The offset slightly differs from package to package, as you might be able to tell in the second image. (That is my character with the Roblox “Boy” arm)
I did measure the offset from the shoulder to the wrist on my character and it comes out to be around (0.45, Y offset is irrelevent, 0.1) studs or something close to that.

It might be a solution to just shift the goal by that offset, but now there is the problem of finding it, which I have no idea how…

Yep, it is pretty inconsistent. I have been recently informed, though, that using inverse kinematics for a live game is not that performant, so I’m switching to animations.

1 Like

Is that so? I wouldn’t think that inverse kinematics would be too performance inefficient, at least not for a game with 20-30 players, unless maybe you were playing on your smart-toaster. :yum:

Besides, loads of games use inverse kinematics for stuff like foot placement, so guns shouldn’t be any different… Although from my experience these games are usually single player and not multiplayer… :thinking:

I’ll look into that some more, maybe I’ll discover that inverse kinematics is not the way to go. Thanks for the suggestion!

Yep, was talking with sircfenner a few days ago (don’t know what brought up the topic), and he said that generally IK is not the solution for real-time.

1 Like

Yea, I thought about it some more and did some testing with my slightly broken IK rig, and I can already tell that IK may not be a good solution for what I wanted to do, so, I will stick with manually animating weapons. Thanks for the insight!

Yeah, the main reason I wanted to use IK was to avoid having to make my own animations (ew!!!), but making my own animations does give more flexibility.