✓ Accepted answer
To achieve this, I would use a combination of raycasting and Magnitude.
First of all, I would fire two rays, one from the position of the first part to the second, and one in the reverse. This would tell you the location of the edge of both parts (on the face)
Secondly, you can get the difference between the two edges and divide it by 2 to get the middle point. From there, you can get the magnitude between the points for the size.
For example:
local function GetPoint(Part1,Part2)
local R = Ray.new(Part1.Position, (Part2.Position - Part1.Position).unit*999)
local Part,Pos = workspace:FindPartOnRayWithWhitelist(R,{Part2})
return Pos
end
local function GetPosAndSizeBetweenParts(Part1,Part2)
local Pos1 = GetPoint(Part2,Part1)
local Pos2 = GetPoint(Part1,Part2)
local MiddlePosition = Pos1 + (Pos2 - Pos1)/2
local Size = (Pos2 - Pos1).Magnitude
return MiddlePosition,Size
end
local Position, Size = GetPosAndSizeBetweenParts(enterpart1here, enterpart2here)
print(Position,Size)
Keep in mind this isn't tested and likely will error, but it might work as an outline.
Hope this helps!
2 comments
#Math
can you explain a bit more on what you are trying to do here, because I see you are using Z with head and neck which is a bit weird. If you are trying to get the height then you need to use Y element of Position.