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

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

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

3 comments

0

What would you rather it do? Should it turn at all during the motion? Should it turn but start with the original rotation?

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.

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.

1 answer

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

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