A while back I posted something about this, but I didn’t actually include a repro. Repro.rbxl (47.9 KB)
What I’m doing;
Spawning 50 Humanoids
Setting all of their parts to one CollisionGroup, excluding a Capsule if it exists
Disabling all unneccesary states; eg climbing/swimming
Telling that CollisionGroup that it can’t collide with itself.
Have the enemies chase me
After a few seconds I begin to lag out hard as they start to overlap. This is extremely prevelant in non-default characters, however it also happens to default characters in some edge cases.
You can change the model that is being used by changing the path it grabs them by in the StarterGui script. Change it to any other name in the Replicated Storage.
Theories for why this might be happening;
Shadows; I’ve just added all my custom npcs, which use CFrame and a ray whitelist, into a Model that has a humanoid, while they were clustered frames drop to 20-30, but once they seperate it goes back up to 60. Link here
(I have tried this in the most recent Future is Bright demo build, there doesn’t seem to be much difference in performance in regards to this issue. This is a negligable theory.)
Collisions; Possibly still checking if they collide with eachother despite being in a non-collide Group.
If you could look at the repro and see how you fair with different models it would be appreciated!
There is a repro attatched, would you be able to look and see what differences you come across?
I was worried about it being shadows too, however when I use a Capsule model to stop them overlapping one another there is still a significant frameloss
Oh, oh boy, I might’ve misread the post. I read one part of it and said “hey, I use collision groups too!”.
The way I use collision groups is setting all the parts of a character to a collision group, that’s about it. I can link a full chunk of code I use in my game in reference to that:
--[[
SpecialRegion.lua
// Author: colbert2677
// Summary: Handles a special region on the map
--]]
local IsHighRank = {}
local function SetPartsCollisionGroup(Part, CollisionGroupName)
-- Sets the collision group of the Part to the second parameter, then calls the function on its children
local PhysicsService = game:GetService("PhysicsService")
if Part:IsA("BasePart") then
PhysicsService:SetPartCollisionGroup(Part, CollisionGroupName)
end
for _, Child in next, Part:GetChildren() do
SetPartsCollisionGroup(Child, CollisionGroupName)
end
end
do
-- Set up collision groups and collidability for slated objects
local PhysicsService = game:GetService("PhysicsService")
local RegionName = "ExecutiveLoungeRegion"
local Region = workspace:WaitForChild(RegionName)
PhysicsService:CreateCollisionGroup("HighRanks")
PhysicsService:CreateCollisionGroup("HighRankRegions")
PhysicsService:CollisionGroupSetCollidable("Default", "HighRanks", true)
PhysicsService:CollisionGroupSetCollidable("HighRanks", "HighRankRegions", false)
PhysicsService:SetPartCollisionGroup(Region, "HighRankRegions")
Region.Transparency = 1
end
do
-- Set up characters for the regions
local Players = game:GetService("Players")
Players.PlayerAdded:connect(function (Player)
IsHighRank[Player] = Player:GetRankInGroup(2957840) >= 11
Player.CharacterAdded:connect(function (Character)
if IsHighRank[Player] == true then
SetPartsCollisionGroup(Character, "HighRanks")
end
end)
end)
Players.PlayerRemoving:connect(function (Player)
IsHighRank[Player] = nil
end)
end
return nil
But that’s probably not what needs to be accomplished here.
I did open up the repro place, results are here. I didn’t seem to experience any lag when they were constantly overlapping. Don’t know if the way they move in that GIF is intended or not.
I’m going to sit on the possibility that your rays might be causing the problem, but after giving this post a deeper read I realize I don’t have a clue what I’m talking about.
Has something to do with the collision physics being ran here. I opened a new place and dropped 50 colliders around the map randomly; no lag or frame drops.
(on a low end machine) changing the collision fidelity of collider to hull reduces lag significantly, changing the collision fidelity to box eliminates the lag
i’d suggest using a tightly-fit bounding box in order to get the best combination of collision and preformance results
I just tried changing the collision fidelity and it eliminated it almost entirely.
Oddly, without doing this, having all the units occupy one space, Anchoring all parts removes the lag, having only the Root removes the lag. But it removes it seemingly perminantly.
i just tested for the overlapping noncollider case and it’s lagging me badly, and changing the collision fidelity of the models doesnt seem to effect preformance
Small mistake I found was the Collisions that are already enabled within the models and not all collisions were set to Box, some were left on Default (not quite sure how.)
I’ve altered this and now the NoCollider seems to run smoothly, however the Collider still have issues.