I’m trying to simulate gravity using the formula G * ((m1*m2)/d). G is the gravitational constant of 6.674, m1 and m2 being the masses of the two objects. Can someone help me understand why the force of gravity is the same for two differently sized objects? For some reason, smaller objects will not move as quickly compared to larger objects. Larger objects will come hurling towards smaller objects as if the smaller object’s gravitational pull is greater.
local ServerStorage = game:GetService("ServerStorage")
local FirstObject = nil
local SecondObject = nil
local UniverseConfigurationModule = require(ServerStorage.UniverseModule)
local SpeedOffset = 10^6
while true do
local Objects = workspace.Objects:GetChildren()
for n, obj in pairs(Objects) do
FirstObject = obj
for n2, obj2 in pairs(Objects) do
if FirstObject ~= obj2 then
SecondObject = obj2
--Gravitation and Spin
local Properties = PhysicalProperties.new(UniverseConfigurationModule.Gravity.Density, .3, .5)
FirstObject.CustomPhysicalProperties = Properties
local G = UniverseConfigurationModule.Gravity.Constant
local m1 = FirstObject.Mass/SpeedOffset
local m2 = SecondObject.Mass/SpeedOffset
local d = (FirstObject.Position - SecondObject.Position).Magnitude
local F = (G * ((m1*m2)/d))
FirstObject.AssemblyLinearVelocity += CFrame.lookAt(FirstObject.Position, SecondObject.Position).LookVector * F
local ObjectUnitVelocity = FirstObject:FindFirstChild("UnitVelocity")
local ObjectForce = FirstObject:FindFirstChild("GForce")
local UnitVelocity, VelocityUnitPerSecond = UniverseConfigurationModule.GetVelocityUnitRate(FirstObject.AssemblyLinearVelocity)
if ObjectUnitVelocity then
ObjectUnitVelocity.Value = UnitVelocity
else
local NewObjectUnitVelocity = Instance.new("NumberValue", FirstObject)
NewObjectUnitVelocity.Name = "UnitVelocity"
NewObjectUnitVelocity.Value = UnitVelocity
end
if ObjectForce then
ObjectForce.Value = F
else
local NewObjectForce = Instance.new("NumberValue", FirstObject)
NewObjectForce.Name = "GForce"
NewObjectForce.Value = F
end
--Collision And Particles
end
end
end
wait()
end