Planet Simulation: Gravity not working

I’ve done the formula correctly yet the LinearVelocity objects have no speed, although they do point at the other planet.

local a = workspace.part1
local b = workspace.part2
local runservice = game:GetService('RunService')

local scale = 1 * (10 ^ 15)
local basedensity = 5560

function gSpeed(mass_a, mass_b, distance)
	local G = 6.67408e-11
	local force = (G * mass_a * mass_b) / (distance^2)
	return force/mass_a
end

function sphere_volume(diameter)
	local radius = diameter/2
	local volume = (4/3) * math.pi * (radius^3)
	return volume
end

while task.wait(0.1) do
	local distance = (a.Position-b.Position).Magnitude * scale
	local massA = sphere_volume(a.Size.Y) * basedensity * scale
	local massB = sphere_volume(b.Size.Y) * basedensity * scale

	a.Attachment.relative.VectorVelocity = (b.Position-a.Position).Unit * gSpeed(massA,massB,distance) 
	b.Attachment.relative.VectorVelocity = (a.Position-b.Position).Unit * gSpeed(massB,massA,distance) 
end
2 Likes

This is not a question, I have no idea what it is you have an issue with. Some sort of planetary rotation system. Without compiling your code in a new place and debugging it myself it’s hard to tell!

1 Like

I have done this before. Perhaps you aren’t using enough force? I remember using something like 9000000000

This is a linearvelocity and takes in a vector3 velocity, not newton force

Well you can take the main point of my reply which was add more so add more velocity then