How do I multiple objects orbit a brick evenly? So, if there are two satellites, they are on opposite sides. If three satellites, space between them is a third. All automatically.
How do I make objects orbit evenly?
1 answer
#Logic
You need to figure out how much to rotate each part in orbit, initially. Once they are placed you may continue to rotate each simultaneously.
A circle has 360º. The quotient of 360 and the number of parts is going to be the summand that will rotate each part in even relation to one another..
360/2 = 60
360/3 = 120
You may use a for loop to easily implement this into the step syntax;
for [variable] = [start],[finish],[step] do
--code
end
#Code
Here is an example ;
local reference = workspace.Part; --Part to orbit
local ps = 3; --Number of parts to orbit
local offset = 1; --Offset from the reference
for i = 1,360,360/ps do --Implement summand into step
local orig = reference.CFrame;
local rot = CFrame.Angles(0,math.rad(i),0); --Assuming this is your axis
local dist = CFrame.new(0,0,-offset);
local p = Instance.new("Part");
p.CFrame = orig*rot*dist;
p.Size = Vector3.new(1,1,1);
p.Anchored = true;
p.Parent = workspace;
end
1 comment
So, I tried to combine your code with someone else's code to make it actually spin. But I am really bad at all this math and comprehension as you can tell, https://pastebin.com/raw/ruEvWHgF. They all end up orbiting at the same angle. Know why?
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
this is not a request site