-
What do you want to achieve?
I want to achieve automatic code that can make a part that looks like this at any size.
-
What is the issue?
I can’t Figure out the equations, nor can I do the math(cause I’m a idiot), to achieve this to be auto matic. -
What solutions have you tried so far?
I’ve googled, and looked on the devforums, BUT, I still can’t find a solution.
This would probably be really complex to generate with a script so what I’d recommend is make this a mesh and store it. Then you can just clone it and re-size it as you would with any part to get various sizes.
Thanks for the help! I didn’t consider that (at first) so I will give it a try.
This can actually be achieved programmatically, this shape is what is referred to as a truncated pyramid. Here’s a function I wrote which can be used to create truncated pyramids of various sizes.
local function generateTruncatedPyramid(size : number) : Model
local model = Instance.new"Model"
local centerPart = Instance.new"Part"
centerPart.Position = Vector3.new()
centerPart.Size = Vector3.new(size/2, size/2, size/2)
centerPart.Parent = model
local topWedgePart = Instance.new"WedgePart"
topWedgePart.Position = Vector3.new(0, 0, -size/2)
topWedgePart.Size = Vector3.new(size/2, size/2, size/2)
topWedgePart.Parent = model
local bottomWedgePart = Instance.new"WedgePart"
bottomWedgePart.Position = Vector3.new(0, 0, size/2)
bottomWedgePart.Orientation = Vector3.new(0, 180, 0)
bottomWedgePart.Size = Vector3.new(size/2, size/2, size/2)
bottomWedgePart.Parent = model
local leftWedgePart = Instance.new"WedgePart"
leftWedgePart.Position = Vector3.new(-size/2, 0, 0)
leftWedgePart.Orientation = Vector3.new(0, 90, 0)
leftWedgePart.Size = Vector3.new(size/2, size/2, size/2)
leftWedgePart.Parent = model
local rightWedgePart = Instance.new"WedgePart"
rightWedgePart.Position = Vector3.new(size/2, 0, 0)
rightWedgePart.Orientation = Vector3.new(0, -90, 0)
rightWedgePart.Size = Vector3.new(size/2, size/2, size/2)
rightWedgePart.Parent = model
local topLeftCornerWedgePart = Instance.new"CornerWedgePart"
topLeftCornerWedgePart.Position = Vector3.new(-size/2, 0, -size/2)
topLeftCornerWedgePart.Orientation = Vector3.new(0, -90, 0)
topLeftCornerWedgePart.Size = Vector3.new(size/2, size/2, size/2)
topLeftCornerWedgePart.Parent = model
local topRightCornerWedgePart = Instance.new"CornerWedgePart"
topRightCornerWedgePart.Position = Vector3.new(size/2, 0, -size/2)
topRightCornerWedgePart.Orientation = Vector3.new(0, 180, 0)
topRightCornerWedgePart.Size = Vector3.new(size/2, size/2, size/2)
topRightCornerWedgePart.Parent = model
local bottomLeftCornerWedgePart = Instance.new"CornerWedgePart"
bottomLeftCornerWedgePart.Position = Vector3.new(-size/2, 0, size/2)
bottomLeftCornerWedgePart.Orientation = Vector3.new(0, 0, 0)
bottomLeftCornerWedgePart.Size = Vector3.new(size/2, size/2, size/2)
bottomLeftCornerWedgePart.Parent = model
local bottomRightCornerWedgePart = Instance.new"CornerWedgePart"
bottomRightCornerWedgePart.Position = Vector3.new(size/2, 0, size/2)
bottomRightCornerWedgePart.Orientation = Vector3.new(0, 90, 0)
bottomRightCornerWedgePart.Size = Vector3.new(size/2, size/2, size/2)
bottomRightCornerWedgePart.Parent = model
return model
end
local truncatedPyramid = generateTruncatedPyramid(8)
truncatedPyramid.Parent = workspace
2 Likes
Wow that looks amazing. Thanks for the function, it’ll help some people I’m sure.