Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Creating a tilted orbit?

Asked by 4 years ago

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

Log in to vote
1
Answered by 4 years ago
Edited 4 years ago
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.

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? radiant_Light203 1166 — 4y
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. Vinceberget 1420 — 4y
Ad

Answer this question