So currently I want to make it where when you move, the rest of the body will follow, however I want it similar to slither.io where the rest of body doesn’t turn right away but it somewhat follows the path that you move in. I’m bad at explaining, basically I want a movement similar to Slither.Io. Any rough ideas on how I would do this?
You’ll want to use inverse kinematics. It would work like so
You can use this simple module I made to solve an Inverse Kinematics set of parts.
local IKFramwork: table = {}
function IKFramwork.SolveIK(segments: table, startPart: BasePart, endPart: BasePart): nil
local prevSegment: BasePart? = nil;
for i = #segments, 1, -1 do
local goalPosition: Vector3? = nil;
local currentSegment: BasePart = segments[i];
-- Set the goalPosition as the endPart if there was not a previous iteration
if (not prevSegment) then
goalPosition = endPart.Position
else
goalPosition = (prevSegment.CFrame * CFrame.new(0,0,prevSegment.Size.Z/2)).p
end
local startPositionOfThisSegment: Vector3 = (currentSegment.CFrame * CFrame.new(0,0,currentSegment.Size.Z/2)).p
-- Set the CFrame from the goalPosition, facing the segment's current start position
currentSegment.CFrame = (CFrame.new(goalPosition, startPositionOfThisSegment) * CFrame.new(0,0,-currentSegment.Size.Z/2)) * CFrame.Angles(0,math.pi,0)
prevSegment = currentSegment
end
end
return IKFramwork
Here’s a place file I made that uses it (originally used to solve someone else’s arm problem): IK test place.rbxl (182.3 KB)
16 Likes
Is there any way I could apply this to meshes?
i know this is an old post but Im working on a snake game and is there any way to make the segments not rotate since I need them to always face upwards