I recently noticed that when I created new instances that were uncollideable, it made the navigational mesh take a very long time to load. I have been experimenting with this mechanic in map for multiple days, and have narrowed it down to the volcanos in the background erupting. When the volcanos are not erupting, the navigation mesh is very quick to load and thus everything is working as intended.
Here are videos showing the behavior:
Working as Intended - Working properly (The NPCs are not freezing)
Volcano Erupted - No Longer Working as Intended - Not working properly (The NPCs are freezing)
Me and another user have possibly narrowed it down to the volcano script itself.
Is this really intense on performance?
local LandingSites = script.LandingSites:GetChildren()
local Volcanos = script.Parent.Volcanos:GetChildren()
while true do
local Volcano = Volcanos[math.random(1,#Volcanos)]
local SFX = script.Rumbling:Clone()
SFX.PlaybackSpeed = math.random(5,10)/10
local BoomSFX = script.Erupt:Clone()
BoomSFX.PlaybackSpeed = math.random(10,13)/10
SFX.Parent = Volcano.Main
SFX:Play()
BoomSFX.Parent = Volcano.Main
for i,v in pairs(Volcano.Main:GetChildren()) do
if v:IsA("ParticleEmitter") then
v.Enabled = false
end
end
wait(math.random(3,8))
SFX:Stop()
for i,v in pairs(script:GetChildren()) do
if v:IsA("ParticleEmitter") then
v:Clone().Parent = Volcano.Main
end
end
for i = 1, math.random(4,6) do
BoomSFX:Play()
for i,v in pairs(game.Players:GetChildren()) do
if v.Character then
local Shake = script.CameraShake:Clone()
Shake.Parent = v.Character
Shake.Disabled =false
end
end
Volcano.Main.Flame.Enabled = true
Volcano.Main.Flame2.Enabled = true
Volcano.Main.Smoke:Emit(200)
for index = 1, math.random(15,25) do
local LandingSite = LandingSites[math.random(1,#LandingSites)]
Volcano.Main.Flame:Emit(15)
local Rock = script.VolcanicRock:Clone()
Rock.Position = Volcano.Main.Position + Vector3.new(math.random(-15,15),math.random(8,15),math.random(-15,15))
Rock.Parent = game.Workspace.NPCStuff
Rock.Size = Rock.Size + Vector3.new(math.random(0,4),math.random(0,4),math.random(0,4))
for i, v in pairs(script.Parent.Structure.Borders:GetChildren()) do
local NoCollide = Instance.new("NoCollisionConstraint",Rock)
NoCollide.Part0 = Rock
NoCollide.Part1 = v
end
local LandingSpot = LandingSite.Position + Vector3.new(math.random(-35,35),math.random(0,25),math.random(-35,35))
-- Calculate Arch --
local TravelTime = math.random(3,5)
local Gravity = Vector3.new(0, -game.Workspace.Gravity, 0)
local StartPos = Rock.Position
local CalculatedVelocity = (LandingSpot - StartPos - 0.5*Gravity*TravelTime*TravelTime)/TravelTime
-- Throw --
Rock.RotVelocity = Vector3.new(math.random(-15,15),math.random(-15,15),math.random(-15,15))
Rock.Velocity = CalculatedVelocity
Rock.Anchored = false
--Rock.HandleRock.Disabled = false
wait(0.1)
end
Volcano.Main.Flame.Enabled = false
Volcano.Main.Flame2.Enabled = false
wait(math.random(3,5))
end
for i,v in pairs(Volcano.Main:GetChildren()) do
if v:IsA("ParticleEmitter") then
if v.Name == "ParticleEmitter" then
v.Enabled =true
else
v.Enabled = false
v.Parent = Volcano.Walls
task.delay(10,function()
v:Destroy()
end)
end
end
end
wait(math.random(180,240))
end