Hello! robert_stevey here. I wanted to contribute to the community by releasing this module I have been working on for a bit.
I introduce you to…
R6 Inverse Kinematics Module
This is a module that solves Inverse Kinematics problem on the limbs of an R6 rig. Now what differentiates this module from other Inverse Kinematics modules is that it simulates what a 2 joint solver on an R6 rig. Dont get it? Well here is a demo of it:
All of this is inspired by BlackShibe in his “Writing FPS Framework, Part 2”
Source
You can get the source of the module here R6IK.rbxm (4.1 KB)
Oh and if you are interested, here is a github for it which includes a documentation too
Thank you, I do remember coming across this post some time ago and I was never able to resurface it for some reason! I’ve been using this module to implement a climbing system, which is coming along pretty nicely.
When i use it the player’s arm starts flying off into the sunset.
Code:
–Some Localscript
local Remote = game:GetService(‘ReplicatedStorage’).Remotes.Grapple
local Plr = game.Players.LocalPlayer
local Mouse = Plr:GetMouse()
local uis = game:GetService(‘UserInputService’)
while task.wait() do
if uis:IsKeyDown(Enum.KeyCode.Q) then
Remote:FireServer(Mouse.hit.Position)
end
end
–Some ServerScript
local Remote = game:GetService(‘ReplicatedStorage’).Remotes.Grapple
local R6IK = require(game:GetService(‘ReplicatedStorage’).Modules.R6IK)
Remote.OnServerEvent:Connect(function(Plr, MouseHit : Vector3)
if Plr.Character then
local IK = R6IK.New(Plr.Character)
IK:ArmIK(‘Left’, MouseHit)
end
end)
I see the problem here, I should have stated this before but you must use the .New function Once and not every time you want to do IK.
So to fix your code, here is the solution that I found. (Server script)
local Remote = game:GetService("ReplicatedStorage").Remotes.Grapple
local Players = game:GetService("Players")
local R6IK = require(game:GetService("ReplicatedStorage").Modules.R6IK)
local PlayerInfo = {}
Players.PlayerAdded:Connect(function(Player)
Player.CharacterAdded:Connect(function()
PlayerInfo[Player] = {IK = R6IK.New(Player.Character)}
end)
end)
Remote.OnServerEvent:Connect(function(Plr, MouseHit : Vector3)
if Plr.Character then
local IK = PlayerInfo[Plr].IK
IK:ArmIK("Left", MouseHit)
end
end)