How would i go about replicating this movement that roblox showed in their Explanation of Ik control i dont really understand how to make this movement with the tutorial they gave:-
Noone? Can show me plssss show me
I did make a very simple script a while back.
Here is the code (paste it into a local script into startercharacterscripts)
local Char = script.Parent
local Humanoid = Char.Humanoid
local RunService = game:GetService("RunService")
local Weight = 0.4
local LeftTarget = Instance.new("Part")
LeftTarget.CanCollide = false
LeftTarget.Transparency = 0.5
LeftTarget.BrickColor = BrickColor.new("Really red")
LeftTarget.Size = Vector3.new(0.5,0.5,0.5)
LeftTarget.Name = "LeftIK"
LeftTarget.Parent = Char
local RightTarget = Instance.new("Part")
RightTarget.CanCollide = false
RightTarget.Transparency = 0.5
RightTarget.BrickColor = BrickColor.new("Really red")
RightTarget.Size = Vector3.new(0.5,0.5,0.5)
RightTarget.Name = "RightIK"
RightTarget.Parent = Char
local LeftLegIK = Instance.new("IKControl")
local RightLegIK = Instance.new("IKControl")
LeftLegIK.Name = "LeftLeg"
LeftLegIK.Parent = Char:FindFirstChild("Humanoid")
LeftLegIK.Type = Enum.IKControlType.Position
LeftLegIK.EndEffector = Char:FindFirstChild("LeftFoot")
LeftLegIK.ChainRoot = Char:FindFirstChild("LeftUpperLeg")
LeftLegIK.Weight = Weight
LeftLegIK.Target = LeftTarget
RightLegIK.Name = "RightLeg"
RightLegIK.Parent = Char:FindFirstChild("Humanoid")
RightLegIK.Type = Enum.IKControlType.Position
RightLegIK.Weight = Weight
RightLegIK.EndEffector = Char:FindFirstChild("RightFoot")
RightLegIK.ChainRoot = Char:FindFirstChild("RightUpperLeg")
RightLegIK.Target = RightTarget
local params = RaycastParams.new()
params.FilterType = Enum.RaycastFilterType.Blacklist
params.FilterDescendantsInstances = {Char,LeftTarget,RightTarget,workspace.CurrentCamera, workspace.Camera} -- workspace camera if you are using a view model
RunService.RenderStepped:Connect(function()
local LeftRay = workspace:Raycast(Vector3.new(Char.LeftFoot.Position.X,Char.LeftFoot.Position.Y+2,Char.LeftFoot.Position.Z),Vector3.new(0,-1,0)*300,params)
if LeftRay then
LeftTarget.CFrame = CFrame.new(LeftRay.Position,LeftRay.Normal)
end
local RightRay = workspace:Raycast(Vector3.new(Char.RightFoot.Position.X,Char.RightFoot.Position.Y+2,Char.RightFoot.Position.Z),Vector3.new(0,-1,0)*300,params)
if RightRay then
RightTarget.CFrame = CFrame.new(RightRay.Position,RightRay.Normal)
end
end)
Humanoid.Died:Connect(function()
if LeftTarget then
LeftTarget:Destroy()
end
if RightTarget then
RightTarget:Destroy()
end
if RightLegIK then
RightLegIK:Destroy()
end
if LeftLegIK then
LeftLegIK:Destroy()
end
end)