So recently i managed to code a system that “cuts” a “wall” into pieces so that a window can fit there, kind of like how bloxburg does in its building mode! https://gyazo.com/7691fe37d8b97db0a9bf50f21e2e6008
Are you trying to make it so that when the part is placed on the wall it cuts a hole through it so the window can look outside? (If this is so I suggest you make the red part transparent)
What? No…
How would that be my problem if i could code something complex like that
Anyway, as i said it is difficult to explain but i will try my best again…
My code currently takes a cutter (red part) and a wall. Wall is a one piece part. Then the wall breaks into 4 pieces, resized and placed in that way so that the cutter(red part) doesnt touch the wall at all.
You can basically say that the red part cuts a hole into a solid piece wall.
Now the issue is shown on 2nd gif. I hope you understand the problem there as i can not really explain it clearly without confusing you…i want that blank area to actually be filled…so wall remains wall
Instead of doing this, I would use CSG as stated above, as it is more efficient than creating 4 different parts, especially when you want to have multiple windows as shown in the video.
So I actually had @alertcoderf ask a similar question not too long ago so I luckily have some code just for this. I don’t claim it’s the most efficient approach since it doesn’t attempt to group like parts, etc, but it works.
Keep in mind, much like your videos the code only works with parts that are relatively axis aligned.
In essence the idea is to first have a function that can slice a part on any of it’s given axes.
Once you have that down cutting out a window is quite simple. You start with a part(s) you want to cut into and slice it up using the surfaces of the window you want to cut out. This leaves you with many cut up parts that make up the original so all that’s left to do is find the parts overlapping with your window and destroy them.
No i wasnt saying to use CSG, it would better to use a bunch of parts, because CSG is not reliable and sometimes the new union does not load. I was asking because i scripted a similar system for the game im working on
I tried using the modules aswell. The touch connection causes studio to crash. I don’t see how you were able to update it live seeing how costly calculation and many loops are used in the module.
local Canvas = game.ReplicatedStorage.Canvas:Clone()
local cut = require(script:WaitForChild("Cut"))
local Window = game.Workspace.Windows.Part
while wait(2) do
local Wall = Canvas:Clone()
Wall.Parent = game.Workspace.Wall
local touching = Window:GetTouchingParts()
cut(Window,touching)
Wall:Destroy()
end