local function getAdditionalLength(angleBetweenWalls)
return math.sin(angleBetweenWalls / 2) * 0.5 / 2
end
local function getAngle(wallDirA, wallDirB)
math.acos(wallDirA.Unit:Dot(wallDirB.Unit))
end
local function checkPreviousPoles(poles, wall, pole1, pole2)
for _, v in pairs(poles:GetChildren()) do
if v.CFrame == pole1.CFrame or v.CFrame == pole2.CFrame then
local Angle = getAngle('Somehow find out which 2 walls need resizing?')
getAdditionalLength(Angle)
print('Done')
end
end
end
checkPreviousPoles(walls.Poles, Wall, Pole1, Pole2) -- Wall is the model, which contains the 2 wall parts
So basically, it is printing when a pole is placed where a previous poles position is. Now, not sure how to include the code to referenced in your first reply.
More context - Each Pole (Pole1 and Pole2) have an ObjectValue inside of them, which has its Value set to whatever wall the said Pole belongs too, that way in the checkPreviousPoles function, you should be able to do pole1.ObjectValue.Value or pole2.ObjectValue.Value to see which wall these poles are connected to. Then using Wall.Wall1 and Wall.Wall2, can resize the 2 newer walls.
I believe you can extract the plugin code from stravant’s resize align?
Visualize these two walls with two parallel lines: The inner and the outer. You want the outer to connect. Drawing two lines straight through the outer ones will connect one “dot”. The whole distance subtracted by the original outer wall length would create the length required.
Next up, you’ll need to CFrame it. Make sure you move 50% of the length towards the “dot”.
I am currently on my phone, so I can’t give the best response. What Bloxburg does to prevent this from happening is that they use a cylinder cut in half at the end of each wall. What I recommend is using the same technique which is adding a cylinder at both ends of the wall. This will automatically join them and you won’t have such problems.
You tackle this problem in 2 ways.
1: Put a part in the gap, either a cylinder or a small block that’s angled properly.
2: You can extend the existing parts.
You can visualize method 2 like this:
Once you do the trigonometry, you can set the size of both of the parts in such a way that the corners overlap exactly. (This method allows you to connect parts that have a different color/material etc.)
I understand that it will make the corners rounded off, and I know that is not the best way to do it. I just wanted to tell how Bloxburg does their walls as it was mentioned in the topic. If you pay close attention, Bloxburg uses this technique to generate their walls. It is also a way that works.
As you can see in the pictures in my question, Bloxburg clearly does not do this. They add a cylinder when placing, but the the wall is placed is a straight block with no cylinders in it
You can see quite clearly that bloxburg walls are not rounded off on the edges
Hey that seems really useful for building making with interiors and decorations, if u ever want to release it you might help a lot of people save a lot of time with the already tedious work of making Unique Buildings for Sandbox games.
As for an answer i have seem some people put a cylinder in the middle of them.
I have a friend who have done this in the past.
The missing triangle has two sides of length 1/2 the wall thickness. It also has a known angle between the two lengths of known length, making this a SAS triangle solving problem. Since the other two angles must be the same (the opposite walls lengths are the same) then we can split this triangle into two right triangles with the hypotenuse being the sides of known length, and one base being 1/2 the gap size. One angle remains the same, one is 90 degrees, and the other is 1/2 the angle between the walls. We can find 1/2 the gap by using the sine of 1/2 the angle between the walls times 1/2 the wall length. If we move each wall this distance towards each other, the gap will be precisely filled. So:
local function getAdditionalLength(wallThickness, angleBetweenWalls)
return math.sin(angleBetweenWalls / 2) * wallThickness / 2
end
Just add this much to each wall length, and since adding to the length changes the size in both directions, move the wall 1/2 that distance towards each other.
The angle between the walls can be found by getting the direction of each wall and finding the unit dot product between them performing:
local function getAngle(wallDirA, wallDirB)
math.acos(wallDirA.Unit:Dot(wallDirB.Unit))
end
How would I be able to check if two walls actually need to be connected tho?? If they place a singular wall, it doesn’t need connecting.
And then, not sure if what you have would work anyway, but if the walls are 90 degrees? Obviously in my example they aren’t but most walls would be 90
The hitbox contains the entire wall, and then wall1 and wall2 are 1/2 the width of hitbox, so there’s 2 sides to the wall. Not sure how it would be possible for the game to check if walls are
Colliding with another
How to tell which part of the wall (wall1 or wall2) to resize
So once we know that the walls need to be connected, the amount each wall will need to be resized will be given by the equations I presented. If the angle between them is 0 or 180 degrees then the sine of that angle will be zero making the distance to resize each wall 0 as well.
Now, to know if the walls need to be connected we need to store some information while placing walls. I assumed that first that after placing two posts to create a wall then you could place a third post to create another wall from the second to the third post. If this were the case, determining which walls to connect would be trivial. If the user must place two posts every time, then I’d implement a snapping system. When a post being placed for a new wall is close to another existing wall’s post, then it snaps to its position and the resulting wall will be connecting using my algorithm above. Note that this may happen to none, one, or both polls (connected to different walls on each end).
When you place one wall, then the wall is placed, but you don’t connect it from post2 - a post3.
It loops back the placing script, creates a post1, and do it all again. So I can place the walls to not be touching any wall, say the first wall would be touching nothing as it’s the first one. Players would place the first wall, then more than likely position the pole1 at the corner of the first wall, and drag and drop the second pole to create the next wall.
Few pics to hopefully explain a lil better
So place the first wall, has nothing to connect to. You can see Pole1 as well, for players to place their next wall
Ah, I see. So since we are not sure if the person wants to connect the walls, or perhaps later build off of only one of the walls, the most modular way to handle this in my mind would be to create a snapping system, and if the user snaps to an existing poll then combine that wall with the newly created one. Am I making sense?
A little bit when the wall is placed tho, the poles are deleted, so that way the edges are straight and not rounded off.
Although…
I could just make the poles invisible that way when placing, I could check if one of the newly created poles is in the same spot as a previous walls pole. Not sure how to do that in the most economical way though? Unless I’d have to do walls:GetDescendants() and just loop thru every single wall and its poles positions until either a pole is found with a matching position.
I’d store each poll and the wall it helped make in a table. The key could be a string of the poll position “x y” and the value an array of the walls connected to that poll. When a poll is placed, check if there was already a poll at that position (since you already are snapping to a grid, correct?) If so, then the new wall will need to be connected to each wall in the list of walls connected to the poll. You’ll then add the new wall to the list of connected walls to that poll.
That should work, but you could perform less connections when you are connecting a third wall to a poll with two or more walls already connected to it.
local polls = {}
local pollKey = '%d %d %d'
local function newPoll(x, y, z, wall)
polls[pollKey:format(x, y, z)] = {wall}
end
local function addToPoll(x, y, z, wall)
table.insert(polls[pollKey:format(x, y, z)], wall)
end
local function getPollWalls(x, y, z)
return polls[pollKey:format(x, y, z)]
end
I ended up getting extremely close to the solution by using the source code of Starvants plugin in a modulescript, from there I just figured out what two faces needed to be checked, to do this I used a poll system. I had two invisible poles one at the end of the wall and one at the beginning, you could check what poles needed to be connected which gave you the face.