Optimising Unanchoring Multiple Parts at Once

Hey!
Alright let’s start with context:
I have a building system where players can build a base and I have another system where if your base gets damaged enough, your whole build crumbles down. This can often be 100s of parts. The parts will never succeed a high number due to a limited build time and placing debounce. To specify, these are all standard Roblox parts (base parts) and there are no meshes or anything with complex hitboxes or geometry.

It’s important to note that I really wanted the builds to crumble or softy explode so I created VectorForce instances at runtime just after anchoring them. I then realised that applying an impulse will help so I swiftly moved over. V3Force felt more organic but it’s a sacrifice I have to make

But I need general optimisation tips for unanchoring multiple parts. Ideally, these parts aren’t being cleaned up or destroyed for a while as I want them to be pushed around for a little bit. Potentially flip flopping from can collide on and off could work but it might be strange.

Is network ownership needed, batching? Any tips would help

Unanchor batch of parts in few frames rather than one

Would a single task.wait() per batch suffice do you think?

local parts = buildingParts
local batchSize = 20 --// tweak this
for i = 1, #parts, batchSize do
	task.wait() --// let physics update
	for j = i, math.min(i + batchSize - 1, #parts) do
		local part = parts[j]
		part.Anchored = false
	end
end
1 Like

yes, that’s one physics update

alright cool thank you i’ll test out varying batch sizes and on mobile too
would setting networkownership to the ‘attacker’ help with something like this or would that just flood that client

if theres only one attacker in a server, then yes, it will be smoother for the client
if you have multiple attackers then its best to leave ownership to server

Yes since you can simply lower the amount of parts in a batch and achieve the same effect.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.