CFrame Legs Procedural Movement R6

hello everyone im trying to make the legs of the character look where the character go
(Im trying to do it with CFrame only, i don’t want to use 8 animations nor inverse kinematics)

here the script i tried :

local LeftLeg = script.Parent:WaitForChild('Torso'):WaitForChild('Left Hip')
local RightLeg = script.Parent:WaitForChild('Torso'):WaitForChild('Right Hip', true)
local CenterOfLegs = Vector3.new(0,-1,0)

local character = script.Parent
local cam = workspace.CurrentCamera
local humanoid = character:WaitForChild("Humanoid")
local RightLegY = RightLeg.C0.Y
local RightLegZ = RightLeg.C0.Z
local RightLegX = RightLeg.C0.X
local CFNew = CFrame.new
local CFAng = CFrame.Angles
local asin = math.asin


while wait(0.001) do
	local movementDirection = cam.CFrame:vectorToObjectSpace(humanoid.MoveDirection).Unit
	-- RightLeg.C0 = CFNew(RightLegX,RightLegY,RightLegZ) * CFAng(0,-asin(movementDirection.x),0) * CFAng(0,0,0)
	RightLeg.C0 = CFNew(RightLegX,RightLegY,RightLegZ) * CFAng(3 * math.pi/2, 0, math.pi) * CFAng(0, 0, -asin(movementDirection.x)) * CFAng(-asin(movementDirection.y), 0, 0)
end

example of what im trying to make: https://www.youtube.com/watch?v=-9DC5_xHiG8
the script work but it’s messed up and i can’t fix it…

2 Likes