I recently stumbled upon a game called “cowboy game” and I want to replicate the leg movement as seen in this video:
I suspect it uses either tweening or IKControls but I want see how to replicate it.
I recently stumbled upon a game called “cowboy game” and I want to replicate the leg movement as seen in this video:
Looks like a custom character controller. Definitely not tweening.
You don’t need to program a custom character controller if you just want procedural movement.
One method would be to fire rays from the foot to find where the next footstep is. Then IK to the point.
Ill try that, but doesnt IK not work on R6?
Not sure, but you might have to delete the default “Animate” script from the character. Then just apply the motor6d transformations from your IK calculations.
I tried this script, and the players legs just stand still (I deleting the “Animate” script fyi)
local PLS = game:GetService("Players")
local RS = game:GetService("RunService")
local distance = 2.5
local height = 25
local speed = 5
local function findPos(origin)
local ray = Ray.new(origin, Vector3.new(0, -5, 0))
local part, position = workspace:FindPartOnRay(ray)
return part and position or origin + Vector3.new(0, -5, 0)
end
local function walk(char)
local hum = char:FindFirstChild("Humanoid")
local rootPart = char.humRootPart
local rightLeg = char["Right Leg"]
local leftLeg = char["Left Leg"]
local rightHip = char.Torso["Right Hip"]
local leftHip = char.Torso["Left Hip"]
local cycle = 0
RS.Heartbeat:Connect(function(deltaTime)
if hum.MoveDirection.Magnitude > 0 then
cycle = (cycle + deltaTime * SPEED_FACTOR) % (2 * math.pi)
local rightOffsetZ = math.sin(cycle) * STEP_DISTANCE
local leftOffsetZ = math.sin(cycle + math.pi) * STEP_DISTANCE
local rightOffsetY = math.abs(math.sin(cycle)) * STEP_HEIGHT
local leftOffsetY = math.abs(math.sin(cycle + math.pi)) * STEP_HEIGHT
--find the position to move the legs to
local rightPos = findPos(rightLeg.Position)
local leftPos = findPos(leftLeg.Position)
--calculate
local rightTarget = rootPart.CFrame:PointToObjectSpace(rightPos + Vector3.new(0, rightOffsetY, rightOffsetZ))
local leftTarget = rootPart.CFrame:PointToObjectSpace(leftPos + Vector3.new(0, leftOffsetY, leftOffsetZ))
--move to
rightHip.Transform = CFrame.new(rightTarget)
leftHip.Transform = CFrame.new(leftTarget)
else
rightHip.Transform = CFrame.new()
leftHip.Transform = CFrame.new()
end
end)
end
PLS.PlayerAdded:Connect(function(plr)
plr.CharacterAdded:Connect(function(char)
walk(char)
end)
end)
Try checking this out
I used this module once, tho for a different purpose.
Works pretty well
I never tried making that leg movement.
I already tried that, and the result didn’t feel like walking, more like stuttering
try adjusting the interpolation period, or reducing the step distance
I created a system to use IKControls and with raycasting, but I dont have the script rn (im on my phone), but it needs a little optimization