Multi is the players size (vector3) and when the player is a bigger size, the legs are inside of the chest, and when they are smaller, they are slightly in the floor. I’m trying to make it so that doesn’t happen
code:
function R6IK:LegIK(Side : "Left" | "Right", Position, Multi)
if Side == "Left" then
local OriginCF = self.Torso.CFrame*self.C0s["Left Hip"]
local C1Off = self.C1s["Left Hip"]
local PlaneCF,ShoulderAngle,ElbowAngle, l3 = SolveLegIK(OriginCF*CFrame.Angles(0, math.pi/2, 0), Position, self.LeftUpperLegLength, self.LeftLowerLegLength, C1Off)
local HipAngleCFrame, KneeAngleCFrame = CFrame.Angles(ShoulderAngle, 0, 0), CFrame.Angles(ElbowAngle, 0, 0)
local HipCF = PlaneCF * HipAngleCFrame*CFrame.new(0,-self.LeftUpperLegLength * 0.5,0)
local KneeCF = HipCF*CFrame.new(0,-self.LeftUpperLegLength * 0.5,0)* KneeAngleCFrame * CFrame.new(0, -self.LeftLowerLegLength*0.5, 0)*CFrame.new(0,(self.LeftLeg.Size.Y-self.LeftLowerLegLength)*0.5,0)
return WorldCFrameToC0ObjectSpace(self.Motor6Ds["Left Hip"], KneeCF, Multi)
elseif Side == "Right" then
local OriginCF = self.Torso.CFrame*self.C0s["Right Hip"]
local C1Off = self.C1s["Right Hip"]
local PlaneCF,ShoulderAngle,ElbowAngle, l3 = SolveLegIK(OriginCF*CFrame.Angles(0, -math.pi/2, 0), Position, self.RightUpperLegLength, self.RightLowerLegLength, C1Off)
local HipAngleCFrame, KneeAngleCFrame = CFrame.Angles(ShoulderAngle, 0, 0), CFrame.Angles(ElbowAngle, 0, 0)
local HipCF = PlaneCF * HipAngleCFrame*CFrame.new(0,-self.RightUpperLegLength * 0.5,0)
local KneeCF = HipCF*CFrame.new(0,-self.RightUpperLegLength * 0.5,0)* KneeAngleCFrame * CFrame.new(0, -self.RightLowerLegLength*0.5, 0)*CFrame.new(0,(self.RightLeg.Size.Y-self.RightLowerLegLength)*0.5,0)
return WorldCFrameToC0ObjectSpace(self.Motor6Ds["Right Hip"], KneeCF, Multi)
end
end
local function WorldCFrameToC0ObjectSpace(motor6DJoint,worldCFrame,Multi)
local part1CF = motor6DJoint.Part1.CFrame
local part0 = motor6DJoint.Part0
local c1Store = motor6DJoint.C1
local c0Store = motor6DJoint.C0
local relativeToPart0 = part0.CFrame:inverse() * worldCFrame * c1Store
local goalC0CFrame = relativeToPart0
return goalC0CFrame
end