-
I want to know how to get the furthest corner/position on an axis
-
Cant figure it out. Works on “straight” axis aka 0,90,180,-90 degree, https://gyazo.com/2389435f0d3c7d87f5cdae1064a9a4a1 ,bec i dont have to care about the furthest out corner and can just use the normal x and z size. But when rotated to for instance 45° here it wont work anymore https://gyazo.com/8f63531f96a3bb795fe6efce26a087be . so in total what i want is this:
but i cant figure it out.
-
I looked up things like finding corners of parts, etc but wasnt able to find what i was looking for
The Code i have so far:
local function ReturnPos(part,base,pos)
local o,size = part:GetBoundingBox()
--print(size)
size = part:GetPivot():VectorToWorldSpace(size)
size = base.CFrame:VectorToObjectSpace(size)
local objectspace = base.CFrame:ToObjectSpace(CFrame.new(pos))
--size = Vector3.new(math.abs(size.X),math.abs(size.Y),math.abs(size.Z))
--print(size)
local MinX,MaxX
local MinZ,MaxZ
local Y = base.Size.Y/2+size.Y/2
MinZ,MaxZ = size.Z/2-base.Size.Z/2,-size.Z/2+base.Size.Z/2
MinX,MaxX = size.X/2-base.Size.X/2,-size.X/2+base.Size.X/2
objectspace = CFrame.new(math.clamp(objectspace.X,MinX,MaxX),Y,math.clamp(objectspace.Z,MinZ,MaxZ))
local worldspace = base.CFrame:ToWorldSpace(objectspace)
return worldspace.p
end
Thanks in advance for any help.



