How can the door snapping onto the wall be achieved? Whats the logic behind this?
You’ll need to cast a ray into the workspace from the camera towards the cursor. If the ray hits a part, check if it’s a valid part to snap too.
Now you have the part you hit as-well as the position of that hit. You can use the parts CFrame values to calculate the proper orientation of the part you want to snap and voila.
I’m glazing over a good chunk of math here, but if you look up examples of using raycasting to spawn parts on the mouse cursor, it’ll make more sense. You should also start with that as an exercise before you try to get the snapping down.
Yes, I understand snapping, but even if I snap it onto the wall, you would not be able to pass through the door.
How is it splitting the walls around the door?
Ah, in that case I’m a little less sure.
An idea you could try out is manually partitioning the part being snapped to into new parts once the user have placed it. You’d probably need some convex hull logic in there to calculate exactly how to partition out the part? You could look up convex hull geometry processing to find some resources.
Also, with that route I’d be unsure how you’d be able to handle meshes… are you strictly working with parts?
This might be too simple for what you’re aiming for, but you might be able to take a hand from the procedural gaming category and do some form of wave function collapse to define the ways these parts can snap together?
Yeah I’m also not quite sure how to make it yet, definitely strictly with a part and not a mesh.
I’m not quite sure what the logic is but games like bloxburg have achieved it so it’d be best to replicate that
try negating the wall?
Whats that, how do you negate?
It’s a part of solid modeling, meaning it creates a union.
If you are ok with unions, the way to do it is BasePart:SubtractAsync()
The format is BasePart:SubtractAsync(Parts, CF, RF)
Where Parts
is a table of parts which you want to use a cookie cutter, CF
is Enum.CollisionFidelity
, and RF
is Enum.RenderFidelity
, both for the resulting union.
Thank you, is there a way to undo the change or you’d just have to replace the wall manually?
Well, studio clearly undoes this easily, but I am pretty sure that you’d have to replace it manually.
Not too hard tho, just clone the wall before negating.
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.