hello, i have made a testscene to see the performance difference between using the ‘Pathfinding’ + ‘Tween’ services to move a Model - vs. using physics objects ‘BodyPosition’ and ‘BodyGyro’.
and there’s a lot of bandwidth usage when using pathfinding, that I don’t understand.
can anyone explain why that is ?
everything is run serverside, and here is the pathfinding code, if that helps:
local PathfindingService = game:GetService("PathfindingService")
local TS = game:GetService("TweenService")
local pathMod = {}
local tweenService = game:GetService("TweenService")
local info = TweenInfo.new(.2, Enum.EasingStyle.Linear)
local function tweenModel(model, CF)
local CFrameValue = Instance.new("CFrameValue")
CFrameValue.Value = model:GetPrimaryPartCFrame()
CFrameValue:GetPropertyChangedSignal("Value"):connect(function()
model:SetPrimaryPartCFrame(CFrameValue.Value)
end)
local tween = tweenService:Create(CFrameValue, info, {Value = CF})
tween:Play()
tween.Completed:connect(function()
CFrameValue:Destroy()
end)
end
function pathMod.FindPath(clone, goal)
local path = PathfindingService:CreatePath()
path:ComputeAsync(clone.PrimaryPart.Position, goal)
local waypoints = path:GetWaypoints()
for i = 1, #waypoints do
tweenModel(clone, CFrame.new(waypoints[i].Position) )
wait(.2)
end
end
return pathMod