Hii! I’m currently making a VR game and I wanted to go along and use Inverse Kinematics for the players arms. I found a forum post on 2 Joint 2 Limb Inverse Kinematics by @LMH_Hutch. I basically set up my arms like how they did in their example but it doesn’t work. I double checked my CFrames and it seems to me I did it correctly. If you can help that would be great, and thanks for reading.
What @LMH_Hutch’s looks like: VIDEO
Mine in VR: VIDEO
My Code Based Off Theirs [This is in RenderStepped]:
--// IK
local leftShoulderCFrame, rightShoulderCFrame = vrCharacter["Torso"].CFrame * leftArmOffset, vrCharacter["Torso"].CFrame * rightArmOffset
local leftGoal, rightGoal = vrCharacter["LeftController"].Position, vrCharacter["RightController"].Position
local upperL, upperR = vector3Up * vrCharacter["ShoulderL"].Size, vector3Up * vrCharacter["ShoulderR"].Size
local lowerL, lowerR = vector3Up * vrCharacter["ElbowL"].Size, vector3Up * vrCharacter["ElbowR"].Size
local leftLaneCF, shoulderAngleLeft, elbowAngleLeft = solveIK(leftShoulderCFrame, leftGoal, upperL.Y, lowerL.Y)
local leftShoulderAngleCFrame = CFrame.Angles(shoulderAngleLeft, 0, 0)
local leftElbowAngleAngleCFrame = CFrame.Angles(elbowAngleLeft, 0, 0)
local rightLaneCF, shoulderAngleRight, elbowAngleRight = solveIK(rightShoulderCFrame, rightGoal, upperR.Y, lowerR.Y)
local rightShoulderAngleCFrame = CFrame.Angles(shoulderAngleRight, 0, 0)
local rightElbowAngleAngleCFrame = CFrame.Angles(elbowAngleRight, 0, 0)
vrCharacter["ShoulderL"].CFrame = leftLaneCF * leftShoulderAngleCFrame * CFrame.new(-upperL * 0.5)
vrCharacter["ElbowL"].CFrame = vrCharacter["ShoulderL"].CFrame * CFrame.new(-upperL * 0.5) * leftElbowAngleAngleCFrame * CFrame.new(-lowerL * 0.5)
vrCharacter["ShoulderR"].CFrame = rightLaneCF * rightShoulderAngleCFrame * CFrame.new(-upperR * 0.5)
vrCharacter["ElbowR"].CFrame = vrCharacter["ShoulderR"].CFrame * CFrame.new(-upperR * 0.5) * rightElbowAngleAngleCFrame * CFrame.new(-lowerR * 0.5)