Midpoints Of Shapes and More!

Hello everyone!

Today, I recently discovered a way of finding a midpoint of multiple points while experimenting with a couple of parts shown below:

Code:

local Model = script.Parent
local RunService = game:GetService("RunService")

local Points = Model.Points

local AmountOfPoints = 0
local Vector3Total = Vector3.new(0,0,0)

local MidPoint = Instance.new("Part")
MidPoint.Size = Vector3.new(2,2,2)
MidPoint.Shape = Enum.PartType.Ball
MidPoint.Name = "MidPoint"
MidPoint.Anchored = true
MidPoint.Material = Enum.Material.Neon
MidPoint.Parent = Model

local function CreateMidPoint()
	for _,Point in pairs(Points:GetChildren()) do
		Vector3Total += Point.Position
		AmountOfPoints += 1
	end
	
	MidPoint.Position = Vector3.new( (Vector3Total.X)/AmountOfPoints , (Vector3Total.Y)/AmountOfPoints , (Vector3Total.Z)/AmountOfPoints )
	
	Vector3Total = Vector3.new(0,0,0)
	AmountOfPoints = 0
end

RunService.Heartbeat:Connect(CreateMidPoint)

Midpoints Of More Complex Shapes

MidpointsOfComplexShapes

Midpoints of Scatter Plots

In the future, I may plan on creating an experience involving the use of midpoints of shapes. Maybe somewhat of an puzzle game or an game involving the use of spells.

Feedback and Ideas with midpoints are appreciated!

5 Likes