-
What do you want to achieve? Keep it simple and clear!
Strider procedural walk animation (Roblox) - YouTube Something kind of like this, if possible, this Adding a Triped Robot To My Weird Shooter Game - Devlog - YouTube -
What is the issue? Include screenshots / videos if possible!
A lack of smoothness, kind of looks like sliding legs. I’d install OBS, but I don’t have much storage to spare. -
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I’ve got a system, but it’s quite a janky mess.
After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
I don’t plan for the system to be super complex this is just an experiment i want to try with code that i’ve been working on, to perhaps make some interesting boss fights.
There’s two scripts to make my system work. Please note, i’ve only recently got the hang of scripting.
This is what’s known as the IK script, a modified version of what okeanskiy used.
local origin = script.Parent
local target = workspace:WaitForChild("target")
local mt = {
__index = function(t,k)
if k == "Head" then
return (t.part.CFrame * CFrame.new(0, 0, -2.5)).Position
elseif k == "Tail" then
return (t.part.CFrame * CFrame.new(0, 0, 2.5)).Position
else
return t.part[k]
end
end,
__newindex = function(t,k,v)
t.part[k] = v
end
}
local segments = {}
for i = 1, 3 do
local part = Instance.new("Part")
part.CanCollide = false
part.CanQuery = false
part.Color = Color3.fromRGB(163, 163, 163)
part.Material = Enum.Material.DiamondPlate
part.Anchored = true
part.Size = Vector3.new(1, 1, 5)
part.CFrame = origin.CFrame * CFrame.new(0, 0, -2.5 - 5 * (i - 1))
part.Parent = workspace
segments[i] = setmetatable({part = part}, mt)
end
local function moveSegment(segment, targetPos)
segment.CFrame = CFrame.lookAt(segment.Tail, targetPos)
segment.CFrame *= CFrame.new(0, 0, -(targetPos - segment.Head).Magnitude)
end
local function moveArmToTarget()
for i = 1, #segments do
moveSegment(segments[#segments], target.Position)
moveSegment(segments[2], segments[3].Tail)
moveSegment(segments[1], segments[2].Tail)
local offset = (segments[1].Tail - origin.Position)
for i = 1, #segments do
segments[i].Position -= offset
end
end
end
while wait() do
moveArmToTarget()
end
and this, marvel (jank-o-lantern) of a script is the pos, the script that moves the origin.
local tweenservice = game:GetService("TweenService")
local core = script.Parent
local part = Instance.new("Part")
local tweeninfo = TweenInfo.new(
1,
Enum.EasingStyle.Quad,
Enum.EasingDirection.InOut,
0,
false,
0
)
part.Anchored = true
part.Position = core.Position
part.Parent = workspace
part.Shape = Enum.PartType.Ball
part.CanCollide = false
part.CanQuery = false
part.CanTouch = true
part.Name = "target"
part.Size = Vector3.new(2,2,2)
part.Color = Color3.fromRGB(255,0,0)
part.Transparency = 0.5
local startgoal = Vector3.new(core.Position.X + 5, core.Position.Y - 11, core.Position.Z - 6)
part.Position = startgoal
while true do
local goal = Vector3.new(core.Position.X + 5, core.Position.Y - 11, core.Position.Z - 6)
print(goal)
local direction = goal - core.Position
local distance = (Vector3.new(core.Position.X, 0, core.Position.Z) - Vector3.new(part.Position.X, 0, part.Position.Z)).Magnitude
wait(0.1)
local raycastResult = workspace:Raycast(core.Position, direction)
print(raycastResult)
if distance > 1 and part and raycastResult then
direction = goal - core.Position
part.Position = raycastResult.Position
print(raycastResult)
end
end
Some code would be nice, but I’m looking for a solution or formula to hopefully follow so i can learn more. (Scripting is fun, and I wanna learn all I can!)
If you can help me out, that would be great. Thanks in advance!
-80s, aka CheemsTheReaper