Part to parts breaker to fit window,door

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

But there was an issue like this
(it is so hard to explain what the problem is and thats why i am going to explain it to you via videos)
https://gyazo.com/ad77b15a0ba5f81175bbdd004061e359

So i “fixed” it with this way:
https://gyazo.com/997bc3a38be7ab6aebc51d59c6158f5d

Now how do i fill that empty area so that it works seamlessly?

15 Likes

Please let me know if you want to see the code i wrote for this and maybe suggest me a solution form there?

2 Likes

Not sure what you mean/What you’re trying to do

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 :joy:

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

May i send you the code privately so that you have a better understanding of the system and may suggest anything?

1 Like

oh you forming parts at the vertices to fill the gaps instead of using CSG like how bloxburg
does it

Sorry, I went afk

Yeah, you can do that and I can take a look at it and try to help

I am not using csg :slight_smile:
I am fragmentating the wall into 4 pieces

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.

You can find the API here:

Example of how to use this:

part:SubtractAsync(window)
1 Like

But this is a very slow task…

1 Like

Luckily i have solved this problem with a really random technique

https://gyazo.com/d638681cefe4675ca242770e9d1c3a63

:innocent:

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.

2019-08-31_11-33-02

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.

2019-08-31_11-26-33

Here’s the placefile:
slice.rbxl (17.7 KB)

51 Likes

You are a life savior! :heart:

Well glad I could help. Sorry I didn’t reply faster I see you came up with your own fix. :grin:

4 Likes

That fix has its own other porblems though :stuck_out_tongue:
https://gyazo.com/3c8af1e24e83473ec22ac1392b880ca5

1 Like

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

1 Like

I have now finally figured out how to use your module on real time and these are the results:

https://gyazo.com/5c7867d88a8e16129d471cfc879c0ee9

You are my hero truly :heart:

13 Likes

Did you store the canvas in a table and it each time the window moved it would give you a new canvas and cut the window then?

Yes somehow like somehow like that i can handle that live update

1 Like

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
1 Like