I watched a procedural animation tutorial on YouTube and followed it, and it works very well. However, it is only normal on the server side, and when viewed from the client, the IK target is pushed back, making it look like a long jump. This NPC with procedural animation follows the player and the game is a multiplayer game. I don’t know if it’s a bug, but I’d like to see this resolved.
I hope the client doesn’t look like it’s normal and jumping like the server.
local hum:Humanoid = script.Parent:WaitForChild("Humanoid")
while true do
task.wait()
if script.Parent.Target.Value then
hum:MoveTo(script.Parent.Target.Value.HumanoidRootPart.Position)
local magnitude = (script.Parent.Target.Value.HumanoidRootPart.Position - script.Parent.HumanoidRootPart.Position).Magnitude
hum.WalkSpeed = 2 + magnitude / 5
else
hum.WalkSpeed = 8
end
end
Walk speed script
local ProceduralModule = require(game.ReplicatedStorage.ProceduralModule)
local runService = game:GetService("RunService")
local enemy = script.Parent
local root = enemy:FindFirstChild("HumanoidRootPart")
local hum = enemy:FindFirstChild("Humanoid")
local alignOrientation = root:FindFirstChild("AlignOrientation")
local target = script.Parent.Target.Value
--// IkTargets
local ikTargets = enemy:FindFirstChild("IKTargets")
local IKTarget1_L = ikTargets:FindFirstChild("Left1")
local IKTarget2_L = ikTargets:FindFirstChild("Left2")
local IKTarget3_L = ikTargets:FindFirstChild("Left3")
local IKTarget4_L = ikTargets:FindFirstChild("Left4")
local IKTarget1_R = ikTargets:FindFirstChild("Right1")
local IKTarget2_R = ikTargets:FindFirstChild("Right2")
local IKTarget3_R = ikTargets:FindFirstChild("Right3")
local IKTarget4_R = ikTargets:FindFirstChild("Right4")
--// Raycast parts
local raycastParts = enemy:FindFirstChild("RaycastParts")
local RayPart1_L = raycastParts:FindFirstChild("Left1")
local RayPart2_L = raycastParts:FindFirstChild("Left2")
local RayPart3_L = raycastParts:FindFirstChild("Left3")
local RayPart4_L = raycastParts:FindFirstChild("Left4")
local RayPart1_R = raycastParts:FindFirstChild("Right1")
local RayPart2_R = raycastParts:FindFirstChild("Right2")
local RayPart3_R = raycastParts:FindFirstChild("Right3")
local RayPart4_R = raycastParts:FindFirstChild("Right4")
--// IKControls
local left1IK = hum:FindFirstChild("Left1_IKControl")
local left2IK = hum:FindFirstChild("Left2_IKControl")
local left3IK = hum:FindFirstChild("Left3_IKControl")
local left4IK = hum:FindFirstChild("Left4_IKControl")
local right1IK = hum:FindFirstChild("Right1_IKControl")
local right2IK = hum:FindFirstChild("Right2_IKControl")
local right3IK = hum:FindFirstChild("Right3_IKControl")
local right4IK = hum:FindFirstChild("Right4_IKControl")
left1IK.Pole = root.LeftPole1
left2IK.Pole = root.LeftPole2
left3IK.Pole = root.LeftPole3
left4IK.Pole = root.LeftPole4
right1IK.Pole = root.RightPole1
right2IK.Pole = root.RightPole2
right3IK.Pole = root.RightPole3
right4IK.Pole = root.RightPole4
--// RaycastParams
local rayCastParams = RaycastParams.new()
rayCastParams.FilterDescendantsInstances = {enemy}
rayCastParams.FilterType = Enum.RaycastFilterType.Exclude
for _,v: BasePart in ikTargets:GetChildren() do
v.Transparency = 1
end
for _,v: BasePart in raycastParts:GetChildren() do
v.Transparency = 1
end
local function BW(waittime)
local start = tick()
repeat
runService.Stepped:Wait()
until tick()-start >= waittime
end
runService.Heartbeat:Connect(function()
target = script.Parent.Target.Value
local rayCast = workspace:Raycast(root.Position, -1000 * root.CFrame.UpVector, rayCastParams)
if rayCast then
local rotateToFloorCFrame = ProceduralModule:getRotationBetween(root.CFrame.UpVector, rayCast.Normal)
local floorOrientedCFrame = rotateToFloorCFrame * CFrame.new(root.Position)
if target ~= nil then
alignOrientation.CFrame = floorOrientedCFrame.Rotation * CFrame.lookAt(enemy.Torso.Position, target.Head.Position)
else
alignOrientation.CFrame = floorOrientedCFrame.Rotation
end
end
end)
while true do
ProceduralModule:IkLegStep(IKTarget1_L, RayPart1_L, enemy.PrimaryPart, 2.75, 1.5, .5, 0.025, rayCastParams)
ProceduralModule:IkLegStep(IKTarget3_L, RayPart3_L, enemy.PrimaryPart, 2, 1.25, .5, 0.025, rayCastParams)
ProceduralModule:IkLegStep(IKTarget2_R, RayPart2_R, enemy.PrimaryPart, 2, 1.25, .5, 0.025, rayCastParams)
ProceduralModule:IkLegStep(IKTarget4_R, RayPart4_R, enemy.PrimaryPart, 2.5, -0.25, .5, 0.025, rayCastParams)
task.wait(1/hum.WalkSpeed*1.25)
ProceduralModule:IkLegStep(IKTarget1_R, RayPart1_R, enemy.PrimaryPart, 2.75, 1.5, .5, 0.025, rayCastParams)
ProceduralModule:IkLegStep(IKTarget3_R, RayPart3_R, enemy.PrimaryPart, 2, 1.25, .5, 0.025, rayCastParams)
ProceduralModule:IkLegStep(IKTarget2_L, RayPart2_L, enemy.PrimaryPart, 2, 1.25, .5, 0.025, rayCastParams)
ProceduralModule:IkLegStep(IKTarget4_L, RayPart4_L, enemy.PrimaryPart, 2.5, -0.25, .5, 0.025, rayCastParams)
task.wait(1/hum.WalkSpeed*1.25)
end
Main script
script.Parent.PrimaryPart:SetNetworkOwner(nil)
Script that tried to solve the problem
Help me please