Skip to content

Instantly share code, notes, and snippets.

@gaymeowing
Last active December 30, 2023 07:48
Show Gist options
  • Save gaymeowing/bc32b5295224026d31c477fe012d3c0d to your computer and use it in GitHub Desktop.
Save gaymeowing/bc32b5295224026d31c477fe012d3c0d to your computer and use it in GitHub Desktop.
Utility function for getting all of a box's corner CFrames
--!strict
-- GetBoxCorners
-- Simple function for getting all of an objects corners
-- Modified From: https://github.com/FrostDracony/Roblox/blob/master/Tutorials/GetCornersOfAllBaseParts/GetCornersOfPart.md
-- @Kalrnlo
-- 25/10/2023
return function(BoxSize: Vector3, BoxCFrame: CFrame?)
local BoxCFrame = BoxCFrame or CFrame.new()
return {
TopUnderRightCorner = BoxCFrame * CFrame.new(-BoxSize.X/2, BoxSize.Y/2, -BoxSize.Z/2),
TopUpperRightCorner = BoxCFrame * CFrame.new(-BoxSize.X/2, BoxSize.Y/2, BoxSize.Z/2),
BottomUpperRightCorner = BoxCFrame * CFrame.new(-BoxSize/2),
BottomUnderLeftCorner = BoxCFrame * CFrame.new(BoxSize.X/2 , -BoxSize.Y/2 , BoxSize.Z/2),
BottomUpperLeftCorner = BoxCFrame * CFrame.new(BoxSize.X/2 , -BoxSize.Y/2 , -BoxSize.Z/2),
TopUnderLeftCorner = BoxCFrame * CFrame.new(BoxSize.X/2 , BoxSize.Y/2 , -BoxSize.Z/2),
TopUpperLeftCorner = BoxCFrame * CFrame.new(BoxSize/2),
BottomUnderRightCorner = BoxCFrame * CFrame.new(-BoxSize.X/2 , -BoxSize.Y/2 , BoxSize.Z/2),
}
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment