I understand that when I run the game in the studio, all the miscalculations happen locally on my computer, and in the case of the server on the roblox server itself.
But the difference in performance is so great that it’s just awful.
I do not understand what logic it works, there is a game “Natural Disaster Survival”, this game has a tornado that physically pushes objects and lifts them.
I implemented the same thing.
In the studio everything works fine, and is indistinguishable from the tornado in that game, but on the server all the objects remain on the floor, and all move very slowly, as if the physics miscalculation engine dies from a couple of objects.
Why is it that the tornado in that game works fine, but in mine can not lift even 1 meter, and everything is very slow.
I have the code absolutely correctly written, no errors, but for some reason when the tornado starts 1 object always rushes to infinity(ONLY 1) , although as soon as it leaves the tornado zone it should stop flying.
That is, something happens that even in theory is impossible, I reread and checked the code 100 times, this even in theory should not happen.
Yes, and it proves that no matter how many objects the tornado touches, they all stop moving as soon as they leave the tornado zone, but constantly at the beginning some 1 does not stop moving, and flies away to infinity.
I don’t want to post all my code, so here is the main part:
-- This is the essence, everything else has no load or meaning to the movement of objects
function MoveUp(obj)
local LinearVelocity = obj.LinearVelocity
LinearVelocity.Enabled = true
local fun
fun = center.Changed:Connect(function()
if not table.find(listObj,obj) then -- Disable when object has left the tornado zone
fun:Disconnect()
LinearVelocity.MaxForce = 9999990
end
-- dist = Distance between the center of the tornado, and objects (formula)
if dist > cycloneRadius then -- if not in the circling area - turn it off
LinearVelocity.VectorVelocity = Vector3.new(0,0,0)
LinearVelocity.Enabled = false
elseif obj.Position.Y > maximumHeight then -- if above the circling zone - turn it off
task.wait(1)
LinearVelocity.VectorVelocity = Vector3.new(0,0,0)
LinearVelocity.Enabled = false
else
LinearVelocity.Enabled = true
-- Here are special formulas for calculating X,Y,Z
LinearVelocity.VectorVelocity = Vector3.new(X,Y,Z)
end
end)
end
while true do
task.wait()
-- The next tornado point is calculated
-- Ovr = Standard (blank)
-- CFrame = Tornado position
-- Size = Vector3.new(60, 220, 60)
local lits = workspace:GetPartBoundsInBox(CFrame,Size,Ovr) -- Finds all objects in a given square
for _, obj in pairs(list) do
task.spawn(function()
if obj.Anchored then return end
if not obj.Parent then return end
if obj.Parent:FindFirstChild("Humanoid") then return end
-- dist = Distance between the center of the tornado, and objects (formula)
if dist < breakRadius then obj:BreakJoints() end
if obj.Mass <= MinMassdeletion and dist < breakRadius then obj:Destroy() return end
if obj.Mass <= deletionMass and dist<deletionRadius then obj:Destroy() return end
if obj.Parent.Parent.Name == "CubicTrees" and dist<deletionRadius then obj:Destroy() return end
if math.random(1,percent) == 1 and dist < deletionRadius then
-- If he is circling in a tornado, the chance of removal is reduced by 3 times
if obj:FindFirstChild("LinearVelocity") and obj.Position.Y > deletionHeight then
if obj.LinearVelocity.Enabled and math.random(1,percent*2) ~= 1 then return end
end
obj:Destroy() return
end
-- If circling in a tornado then
if dist < cycloneRadius and obj.Position.Y < maximumHeight then
if obj.Mass < cycloneMass then return end
if not (math.random(1,50) == 1 ) then return end
if obj:FindFirstChild("Attachment") then
local LinearVelocity = obj.LinearVelocity
-- 9999990 - means that the object is out of the tornado's range(That is, the function has been disabled)
if not LinearVelocity.Enabled and LinearVelocity.MaxForce == 9999990 then
LinearVelocity.MaxForce = 9999999
MoveUp(obj)
end
else
local Attachment = Instance.new("Attachment")
Attachment.Parent = obj
local LinearVelocity = Instance.new("LinearVelocity")
LinearVelocity.Parent = obj
LinearVelocity.Attachment0 = Attachment
LinearVelocity.MaxForce = 9999999
MoveUp(obj)
end
end
end)
end
end
I don’t see anything here that’s a big load.
screenshots with load data
Just now I tried running a tornado right away, and it seems to work, but the further it goes, the worse it gets.
That is, if I start the tornado at once, the first few seconds everything seems fine, and then it gets worse.
But if I run it after 1-2 minutes of play, the tornado starts working very badly right away.
In my game there are no cycles that somehow increase the load all the time.
The load at the start of the server, and after an hour will not change in any way (unless I turn on the tornado)
Can it be that the more players on the server + the more your game is played, the more capacity will be allocated to the game by roblox?