Inverse Kinematics Module - Easy Solver

I have created an Inverse Kinematic module for easy use and easy configuration to make your very own IK controller!

I have modified an Inverse Kinematics formula from YouTube and made it a modular system, with a few functions:

Module.new(), which creates an IK class.

Class:Solve(), for solving arm IK.
Class:AdvancedSolve(), for solving leg IK.

The two already built in functions for R15 IK are:
Class:SolveArm()
Class:SolveLeg()

Further documentation is in the description and the actual module.

https://www.roblox.com/library/5727195167/IK-Module

Examples of how I have used the IK module:
iXGRSHd0BC-min
LRZDUilM9m-min

106 Likes

How do I activate the module and put in onto the character??

5 Likes

Using the Module.new() function, you need to specify 4 parameters to initialize an R15 IK rig, as documented. This is entirely optional if you don’t want to use it on one.

Hook a script up (local script or server script) to StarterCharacterScripts, and have some code that is like this (sort of):

local RunService = game:GetService("RunService")
local Character = script.Parent

local Module = require(YourIKModulePath)
local IK = Module.new() -- R15: UpperTorso, LowerTorso, Humanoid, HumanoidRootPart

RunService:BindToRenderStep("YourLegRender", 1, function()
    -- do your IK stuff here
end)

This should be all you need to initialize the IK.

8 Likes

I’m trying to make it only solve when the ray hits an object, but it seems to only solve it when the player is moving. Once again this IK module only allows for 2 joints as it uses the law of cosines which can only be used to determine 2 thetas. It’s a very restricted module as some may want to use more than 2 joints, that’s why I think FABRIK is still the best option. Regardless, the module was very readable and it could use more comments like what variables are optional/needed, e.g. the fact that the Hip/Knee variables need to be the original C0 for those joints and not the joints themselves. (I think). In your gifs you showed it working with an idle pose that maintains a very still position, I haven’t tested it but how do you think it will work with animations? I’ve used almost the same method of solving leg/arm inverse kinematics, it looked fine except when I started walking/running the legs look super weird. An entirely IK based rig is definitely what should be shot for, foot planting alone can look very weird with default Roblox animations.
The module itself has no issues but I would prefer more documentation. It’s still slightly lacking in terms of usability compared to other methods, but since you just made it an easy module I won’t put that on you.

4 Likes

Hey there,
I do believe that I need to add some more documentation, but I was mostly aiming for two jointed Inverse Kinematics motion (which is why it only supports R15). I do believe that it can support more joints if you use the module’s :Solve() in something like a chain, but this is untested. I’ve tested out using regular ROBLOX animations with the IK module, and with the Oldschool animation pack (the one I have on right now), it looks quite weird, which is why you only see a full IK rig in the provided examples.
Your raycast solving only when the player is moving may be due to your code, unless your ray code is running every step or without any type of movement checks. I’ll definitely change the Hip and Knee parameters since it is very confusing at first glance (I believe some of the documenting inside of the module would explain that?).

Overall, really good criticism! I’ll be taking this into thought and may update my module to fix the given issues.

3 Likes

Sorry to other you again, I am a rookie scripted and for some reason it is still not working for me. I have a starter character. What exactly should I put to make the character be completely animated using the module - just like the demo videos? Sorry to bother you I am a noob :laughing:

2 Likes

How did you do that?
Can you send the script please?
Thanks :smile:

4 Likes

Sorry- It has some very important things needed for it to work. You would need to replicate all the scripts. I will uncopylock my testing place, though, for you to test it out!

Here:

12 Likes

You may check out the testing place above this reply.

1 Like


I tried to bind the arm to two attachments on the gun but this is what happening.
Could you please tell me what is wrong with it?

if Handle:FindFirstChild("LeftWeld") then

	local NewLeftShoulder,NewLeftElbow = IKcharacter:SolveArm(Handle.Position + 
Handle.LeftWeld.Position, character.LeftUpperArm.LeftShoulder.C0, 
character.LeftLowerArm.LeftElbow.C0)

	character.LeftUpperArm.LeftShoulder.C0 = NewLeftShoulder
	character.LeftLowerArm.LeftElbow.C0 = NewLeftElbow
	
	local Repp = game.ReplicatedStorage:FindFirstChild("ReplicateJoint")

	if Repp then
		Repp:FireServer({character.LeftUpperArm.LeftShoulder,character.LeftUpperArm.LeftShoulder.C0},{character.LeftLowerArm.LeftElbow,character.LeftLowerArm.LeftElbow.C0})
	end
end

if Handle:FindFirstChild("RightWeld") then

	local NewRightShoulder,NewRightElbow = IKcharacter:SolveArm(Handle.Position + Handle.RightWeld.Position, character.RightUpperArm.RightShoulder.C0, character.RightLowerArm.RightElbow.C0)
	character.RightUpperArm.RightShoulder.C0 = NewRightShoulder
	character.RightLowerArm.RightElbow.C0 = NewRightElbow
	
	local Repp = game.ReplicatedStorage:FindFirstChild("ReplicateJoint")

	if Repp then
		Repp:FireServer({character.RightUpperArm.RightShoulder,character.RightUpperArm.RightShoulder.C0},{character.RightLowerArm.RightElbow,character.RightLowerArm.RightElbow.C0})
	end
end

Ikcharacter is a class created with proper parts

And this is when I put the handle’s position instead of attachment poses
Completely JOJO reference XD

2 Likes

Is it possible to use it with lightsaber or blaster?

Make sure you store the original Shoulder and Elbow C0s, so it doesn’t glitch like that.

Yes! Any tools can have inverse kinematics applied to them.

1 Like

Can I ask what does Clamps do?

How it worked? Did it need a animations or use IK animations? (I can’t figure out how to make IK animations work with the IK script)

You do not need to add animations for the Inverse Kinematics to work

1 Like

The clamps are optional variables, they’re just there incase you want to change them.

1 Like

oh okay, so I liked it :smile: I think it look good for my game.

1 Like

Um… why it doing this?

2 Likes

You’re probably trying to blend the default arm animations with the IK animations, I can’t remember if Transform or C0 was done to achieve this but you’d probably want to set the Arm’s frame without blending it with the default walk animations.