How do I find the position of a surface on a part?

Lets say I have a 3 by 3 by 3 block and I know the positions and lookvectors of that block. Is there a way I can find the center of where the front or back surfaces are on that part? So move from the parts position in the lookvector half the parts size. How do I do that?

2 Likes

You can get the LookVector of the part, then multiply the LookVector by half of the Part’s Size on the Z axis to get the center of front of the part:

local Center = Part.CFrame.LookVector * (Part.Size.Z / 2)
8 Likes

For anyone that needed to find the position of all sides, this function should work. (Even if the part has been rotated)
Based on @VegetationBush solution, this function will get all the surface positions for an entire part and return it as a dict. :wink:

local function getPartSurfacePositions(Part)
	local sides = {
		front = Part.CFrame.LookVector * (Part.Size.Z / 2)+Part.Position,
		back = -Part.CFrame.LookVector * (Part.Size.Z / 2)+Part.Position,
		right = Part.CFrame.RightVector * (Part.Size.X / 2)+Part.Position,
		left = -Part.CFrame.RightVector * (Part.Size.X / 2)+Part.Position,
		up = Part.CFrame.UpVector * (Part.Size.Y / 2)+Part.Position,
		down = -Part.CFrame.UpVector * (Part.Size.Y / 2)+Part.Position,
	}
	return sides
end
1 Like