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

Orbiting a part around another resets the part's orientation?

Asked by
Sublimus 992 Moderation Voter
9 years ago

I have a part m1.Top that orbits around part orange. This works fine, the only problem is that instead of maintaining the rotation it had before the orbit starts, it resets the rotation of m1.Top.

How can I fix this problem?

Code:

for i = 1,180 do
    wait()
    m1.Top.CFrame = CFrame.new(orange.Position) * CFrame.Angles(0, math.rad(i*2), 0) * CFrame.new(0, 0, (orange.Position - m1.Top.Position).magnitude)
end
0
What would you rather it do? Should it turn at all during the motion? Should it turn but start with the original rotation? BlueTaslem 18071 — 9y
0
It's a Quarter-Circle, and I'd like the vertex of the two straight sides to face 'orange', but in it's current form, it should be maintaining it's rotation and just orbiting the 'orange' part. Sublimus 992 — 9y
0
And for it to face the 'orange' part, I could really just have a separate piece rotating it proportionally to where it is in it's orbit. Sublimus 992 — 9y

1 answer

Log in to vote
0
Answered by
Sublimus 992 Moderation Voter
9 years ago

I did it.

local x,y,z=m1.Top.CFrame:toEulerAnglesXYZ()
        for i = 1,180 do
            wait()
            m1.Top.CFrame = CFrame.new(orange.Position) * CFrame.Angles(0, math.rad(i*2), 0) * CFrame.new(0, 0, (orange.Position - m1.Top.Position).magnitude) * CFrame.Angles(x,y,z)
        end
Ad

Answer this question