How did they do that in BloxBurg?

[warnning] poster’s English is bad

As we can see, when I move the door frame in bloxburg, the hole in the wall move together very smoothly.

I want to achieve the same effect and I guess bloxburg is calling SubtractAsync every time I move the door, here is my code and result video.

local wall = workspace.wall  -- transparent part
local negative = workspace.negative  -- transparent part, smaller than wall
local negCframe = negative.CFrame 
local union  -- record old union and destroy it when new uion is created


function setPart(part:Part)
	part.Transparency = 0
	part.CanCollide = true
end


while task.wait(0.1) do
	local newCframe = negative.CFrame
	if newCframe ~= negCframe then  -- simulate mouse moving
		negCframe = newCframe
		local copyWall = wall:Clone()
		local copyNegative = negative:Clone()

		setPart(copyWall)
		--setPart(copyNegative)

		copyWall.Parent = workspace
		copyNegative.Parent = workspace
		newUnion = copyWall:SubtractAsync({copyNegative})
		if newUnion then
			newUnion.Parent = workspace
			
			if union then   -- destroy last union
				union:Destroy()
			end
			copyWall:Destroy()
			copyNegative:Destroy()

			union = newUnion
		end
	end
end


lack fluency

Am I thinking in the wrong direction? How did they do that in BloxBurg?

4 Likes

Looking at the code your seem to be doing it every 0.1 seconds. If you want it to be smoother you could try using RunService.Heartbeat so it changes every frame

while game:GetService("RunService").Heartbeat:Wait() do
	--blah BLAH balglallaklsd
end

If runservice is still too slow try using RenderStepped

while game:GetService("RunService").RenderStepped:Wait() do
	--blah BLAH balglallaklsd
end

Thank you for your time!!!
I tried RunService.Heartbeat, then the hole only appears when I stop moving, I guess copyWall and copyNegtive is created every frame but it takes some time for SubtractAsync() to union two parts, so the hole only appears when the copy parts stop being created.

RenderStepped must be called in LocalScript but SubtractAsync can only be called in Script, so RenderStepped is not suitable here.

I tried another thing, not put the copyWall and copyNegtive in the workspace, but in the replicated storage, looks better but still not perfect.

This is not using the CSG API as it would need to be called on the server-side, instead, Bloxburg uses a custom wall slicer solution. I really recommend you to learn basic vector maths in order to create your own slicer system from scratch.

1 Like

thx for the recommendation!! But could you tell me some details about ‘custom wall slicer solution’?

Looks to me like the effect could easily be done by dividing the wall into 3 parts and resizing them based on where the door is

Well, it is based on getting the edges of the cutter(BasePart) and the edges of the target(i.e. CutterLeft, TargetLeft) and then, comparing how much distance is between these two so you can create a Part that is sized to that number and make the ilusion of a piece of the original target part.

Note that there are other ways to get this same effect, but as far as i know, this is the most optimized one.

Thank you very much! I’ll try this way.

You are right, but we can place a complete wall part in bloxburg building mode, so I didn’t think about it that way.
May be when I move the door frame, bloxburg cut the wall part?