As i can tell, this seems to have gone unnoticed. Here is a free place that someone created with the same inverse that the video uses. (i assume you found this post) How to make a snake like movement, I have edited the model in a way so you dont need connectors and you can slightly mash it together for better results.
- Module to put into
game.ReplicatedStorage
local IKFramwork = {}
function IKFramwork.SolveIK(segments, startPart, endPart)
local prevSegment = nil;
for i = #segments, 1, -1 do
local goalPosition;
local currentSegment = 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.2)).p
end
local startPositionOfThisSegment = (currentSegment.CFrame * CFrame.new(0,0,currentSegment.Size.Z/2.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.2)) * CFrame.Angles(0,math.pi,0)
prevSegment = currentSegment
end
end
return IKFramwork
- Script to put into your snake model
local rightArmPrimary, gunGrip = game.Workspace["S-SpawnArea"] --[[Here clone the head into workspace and name it S-SpawnArea.]], script.Parent.Head.Head --[[Change this to your snakes head instance.]]
local RS = game:GetService("RunService")
local Framework = require(game.ReplicatedStorage.IKFramwork)
local rightArmSegments = {script.Parent.seg7.main,script.Parent.seg6,script.Parent.seg5,script.Parent.seg4,script.Parent.seg3,script.Parent.seg2,script.Parent.seg1} --[[Change segments here to your snakes segments (no connectors needed, just union your connectors together.), If your snake is backwards while implementing this part, reverse the instances in the table
(Example:
local rightArmSegments = {script.Parent.seg7,script.Parent.seg6,script.Parent.seg5,script.Parent.seg4,script.Parent.seg3,script.Parent.seg2,script.Parent.seg1}
converts to:
local rightArmSegments = {script.Parent.seg1,script.Parent.seg2,script.Parent.seg3,script.Parent.seg4,script.Parent.seg5,script.Parent.seg6,script.Parent.seg7}
)]]
RS.Heartbeat:Connect(function()
Framework.SolveIK(rightArmSegments, rightArmPrimary, gunGrip)
--Framework.SolveIK(leftArmSegments, leftArmPrimary, gunHandle)
end)
I hope i explained this well enough for you to bring your beautiful snake model to life,
And also for learning experience, The framework uses a simple CFrame calibrator to change CFrames relative to heads current movement. (You moving the head to change the snakes position orientations, like the video you have attached in the original post.), SHOULD result in this:
robloxapp-20220626-1233138.wmv (762.8 KB)