Simple orbit physics!

I made my own orbit physics even months ago, This is based from a non-roblox related minigame I made with another person some time ago, where you could launch debris rocks and orbit them around the sun. Now, I decided to make it an actual thing and you can finally create your own objects with orbit physics.

You can also try the test place here, It’s uncopylocked so you may take the module there too.

API Reference:

-- Constructors:, Speed:Vector3):Physics -- Creates a new orbit physics object.
-- Properties:
Physics.Position:Vector3 -- The position of the object.
Physics.Speed:Vector3 -- The speed or velocity of the object.
-- Functions (Physics)
Physics:Attract(Target:Vector3,Influence:number):Physics -- Modifies the speed to attract the object to a location.
Physics:Repel(Target:Vector3,Influence:number):Physics -- Modifies the speed to repel the object from a location.
Physics:Slow(Influence:number):Physics -- Slows down the velocity of the object.
-- Functions (Setting)
Physics:SetPosition(Target:Vector3):Physics -- Sets the object position.
Physics:SetSpeed(Target:Vector3):Physics -- Sets the object velocity.

You can chain functions, like for example:


And, here’s an example function for all of you:

local,,.5,0)) -- Create a physics object
while task.wait()do -- Repeat forever
	for i,x in {,10,0),,10,25)}do -- in both positions
		Physics:Attract(x,math.max(1-((x-Physics.Position).Magnitude/1000),0)*.02) -- attract to them, far objects doesnt get attracted.
		if(Physics.Position-x)<5 then -- if too close
			Physics:Destroy() -- destroy object
			break -- break loop
	Physics:Update():Slow(.0002) -- update loop and slow object down.
	-- you can set a part's position to Physics.Position

Give me your feedback on what do you think of this module!


Do you have examples in a .rbxl to check out?


I’ll eventually do that since sounds easy, no worries :smiley:
edit: @Lord_BradyRocks, I finished the test place!

oops I just made a typo and typed ‘Attact’ instead of ‘Attract’, the post should be fixed now.