
573 Views
120 Executions
Does it work?
No reports yetNo reports yet. Tried it? Be the first to say.
Also noticed:
Description
Com offset
local model = script.Parent
local RunService = game:GetService("RunService")
-- Create the visual marker
local marker = Instance.new("Part")
marker.Shape = Enum.PartType.Ball
marker.Size = Vector3.new(0.6, 0.6, 0.6)
marker.Material = Enum.Material.Neon
marker.Color = Color3.fromRGB(255, 0, 0)
marker.Anchored = true
marker.CanCollide = false
marker.Name = "CenterOfMassMarker"
marker.Parent = workspace
-- Function to calculate true center of mass
local function getCenterOfMass()
local totalMass = 0
local weightedPosition = Vector3.zero
for _, part in ipairs(model:GetDescendants()) do
if part:IsA("BasePart") then
local mass = part:GetMass()
totalMass += mass
weightedPosition += part.Position * mass
end
end
if totalMass == 0 then
return nil
end
return weightedPosition / totalMass
end
-- Update every frame
RunService.Heartbeat:Connect(function()
local com = getCenterOfMass()
if com then
marker.Position = com
end
Comments
0Log in to join the conversation. Login
No comments yet. Be the first!








