So I have 4 attachments that act as corners, and a block with wedge sides.
How would I resize the block and wedges to fit to the attachments?
I’m not quite sure what you mean by this
What are you trying to resize it for / to?
So the corner attachments you see are parented to the block behind the side. I want this shape (the dark part and wedges) to stretch to these attachments.
So if I were to move one of these attachments, the side would resize and reshape to stretch across the corner attachments.
Group them, or make a MeshPart.
Hang on, I’m testing some code in studio.
It should be as simple as using some math to subtract half the size of the dark gray part and then getting the attachment position relative to the center of the dark gray part - the size/2 and resize the triangles.
Uhh well they are grouped and if it was a meshpart, how would it reshape?
@MrLonely1221 heres an example of what I mean. (it is currently beams but i want parts w/ shadows)
Well, the mesh part will stretch vertically and horizontally.
There used to be a really good tutorial for this, and I can’t remember what it was called or how to find it…
What you would be doing here is having 2 triangles, and then resizing and positioning them so that the 3 points meet up with 3 of the parts. So you would need to find the middle of the 3 points in space, then find the size needed to make the triangle hit all 3 points, then rotate it to match the angle the 3 points are making.
yeeaaahhh but isnt that the exact same as a normal part? A part can stretch vertically and horizontally too. Plus, this is stretching in very odd ways, not vertically and horizontally.
I thought you meant that it will stretch like a MeshPart…
So it would end up looking like this.
There’s going to be a good bit of math involved behind it to get the rotation it needs to be at.
sry i dont understand anymore, but the only way for a meshpart to stretch like I want it to is if the corners were rigged (had bones)
Yeah basically but ofc the other side and middle.
Actually, the more I think about it, is it possible to be just 2 triangles?
wait what lmao same thoguht
but yes thats exactly what i need
Yes, for every 3 vertices you have it would just be another triangle.
Um just a quick question, do you have studio literally breaking and becoming unusable every other time you open it?
(and nearly every single time you open any plugin)
Yes.
Also, here’s a little equation I did to find the middle. This doesn’t solve for the rotation the triangle needs to be at, or the size, just the position for the middle.
--Just ran this in the command bar.
a,b,c,d = table.unpack(game.Selection:Get());
a.Position = b.Position - ((b.Position - c.Position) / 2) - ((b.Position - d.Position) / 2);
a.Size = Vector3.new(0.1, (b.Position - d.Position).Magnitude, (b.Position - c.Position).Magnitude);
I selected the parts in the order of, Wedge, Part at the bottom left, then the part to the right, then to part at the top.
Edit: The math breaks if you move either the top point back past the bottom left, or the right point down below the bottom left…
tbh I am baffled at the code because i dont know how to use command bar nor wtf is a,b,c,d = table.unpack(game.Selection:Get()); lol
a, b, c, d = table.unpack(game.Selection:Get())
-- table.unpack breaks a table apart and returns a tuple i.e.,
--[[
local tbl = {
"Hello",
"World!"
}
local hello, world = table.unpack(tbl)
print(hello, world)
--Expected output: "Hello World!"
]]
game.Selection:Get()
--game.Selection is the selection service in Roblox studio, each time you select
-- a instance it gets added to this table in the order you selected it
-- i.e., control clicking, or shift clicking another part
--This is useful for getting what you currently have selected in studio and can be used for moving one part to another part's CFrame by simply selecting both parts, and then using game.Selection:Get() (Which returns a table as stated before) and then set the CFrame of one to the other.
a, b, c, d = ...
-- a, b, c, d was just me setting junk variable names for testing out moving the triangle.
References:
table.unpack
Selection