In my example, I'm going to have two parts as a visual: a blue part that is representing our part we want to get the position of and a red part that represents our position we want to get. links are visuals of each step.
Picture of the two parts
originalPart is our blue part
positionPart is our red part
Anyway, you didn't specify which direction was north, so I'm going to say the front face of the blue part is north.
We first want to put the red part at the cframe of the blue part so they have the same rotation:
positionPart.CFrame = originalPart.CFrame
We first want to shift the red part forward originalPart.Size.Z/2 studs on the z axis:
positionPart.CFrame = positionPart.CFrame * CFrame.new(0,0,-originalPart.Size.Z/2)
Then we'd want to shift the part to the right originalPart.Size.X/2 studs in the x-axis:
positionPart.CFrame = positionPart.CFrame * CFrame.new(originalPart.Size.X/2,0,0)
and then lastly, shift the red part up originalPart.Size.Y/2 studs in the y-axis
positionPart.CFrame = positionPart.CFrame * CFrame.new(0,originalPart.Size.Y/2,0)
You end up with the red part in the north east corner
You can do this all in one step by saying:
positionPart.CFrame = originalPart.CFrame * CFrame.new(originalPart.Size.X/2,originalPart.Size.Y/2,-originalPart.Size.Z/2)
#Full Code:
local originalPart = Instance.new("Part")
originalPart.CFrame = CFrame.Angles(math.rad(20),0,math.rad(5))
originalPart.Parent = workspace
originalPart.Color = Color3.fromRGB(0,0,255)
local positionPart = Instance.new("Part")
positionPart.Parent = workspace
positionPart.Color = Color3.fromRGB(255,0,0)
positionPart.Size = Vector3.new(.5,.5,.5)
positionPart.CFrame = originalPart.CFrame * CFrame.new(originalPart.Size.X/2,originalPart.Size.Y/2,-originalPart.Size.Z/2)
1 comment
This is very interesting, can you elaborate?