Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Creating a tilted orbit?

I can create an orbit within a flat plane, that shouldn't be too much of a problem since all I really need to do is use the parametric equation for a circle/oval and position the orbiting part accordingly, like so:

while wait() do
	local t = tick() * 2 * math.pi * X -- X is the time of orbit
	local o = Vector3.new(math.cos(t), 0, math.cos(t)) -- or any combination of the two
	part.CFrame = CFrame.new(mainPart.Position + o * R -- R is the separation
end

How would I create a circular orbit out of the plane?

1 answer

✓ Accepted answer
while wait() do
	local t = tick() * 2 * math.pi * X
	local tilt = math.rad(15)
	local o = Vector3.new(math.cos(t), math.cos(t) * math.sin(tilt), math.cos(t))
	part.CFrame = CFrame.new(mainPart.Position + o * R)
end

This was the best I could come up with. But since I lack the knowledge about orbits and such I think this might simply not work. If you provide more context I might be able to figure it out.

2 comments

1

Thanks for replying! Adding a cos(t) makes the orbit elliptical and out of the plane (just what I needed). Can you explain why you thought of this?

1

@radiant_Light203. With the lack of context I was provided I decided to be safe (since I didn't know the exact properties of the X and R value) and use math.cos(t) instead. Since cos(t) returns the X (and Y) value of "o" I decided to use it instead. I then made the Y value change depending on the point of the orbit which is referenced.

This discussion is preserved as it was. New answers, comments, and votes are closed.