-
What I want to achieve:
Hello, I’m trying to make an orbital system where planets orbit around a sun at a random velocity/speed. To be very clear: I am not using CFrame, This is based on pure Roblox physics using a LineForce. -
The issue:
I cannot seem to find the right formula to use so that, regardless the size of the planet, the magnitude will always be the right amount for a stable orbit. -
What solutions have you tried so far?
I have tried googling up formulas for stable orbits using Mass,Velocity and Magnitude, but all I can find are very complicated formulas that use symbols that I am not familiar with(I’m 14 years old so I am not an expert when it comes to math in any way, I just wanna make cool space stuff). I’ve also searched around on the forums, but I can’t find anyone who is specifically trying to achieve what I am.
Here’s the code:
--//Objects
local Planet = script.Parent
local Sun = script.Parent.Parent
--//Attachments + lineforce
local LineForce = Instance.new("LineForce")
local Attatchment0 = Instance.new("Attachment")
local Attatchment1 = Instance.new("Attachment")
--//Setting up the attachments and lineforce
Attatchment0.Parent = Planet --// Putting attachment0 in the planet
Attatchment0.Visible = true --// Making Visible
Attatchment1.Parent = Sun --// Putting attachment1 in the sun
Attatchment1.Visible = true --// Making Visible
LineForce.Parent = Planet --// Putting the lineforce in the planet
LineForce.Attachment0 = Attatchment0 --// Aplying attachment0 to the lineforce
LineForce.Attachment1 = Attatchment1 --// Aplying attachment1 to the lineforce
--//Ticking all the boxes in the lineforce
LineForce.ApplyAtCenterOfMass = true
LineForce.ReactionForceEnabled = true
LineForce.InverseSquareLaw = false
LineForce.Visible = true
local RanVel = math.random(100,500) --// Choosing a random velocity(the speed at which I want the planet to orbit)
Planet.Velocity = Vector3.new(0,0,RanVel) --// Aplying the velocity to the planet
LineForce.Magnitude = --//??? this is the part where im stuck, I don't know the formula :( Is there even one?
Quick sidenote: This is my first topic on the DevForum. Feedback is free to give and recieve so I’ll take any! For the rest thank you for reading!
EDIT: If you’re reading this edit then don’t waste your time trying to help me with this. I’ve already given up. If you wanna know why just read all the replies under this topic. It was lovely to see how nice people are here. I just don’t want to tell everyone the dissapointing news that i gave up after they spent their time trying to solve my problem. I’ll probably take on this another time when i’m better at Lua.